-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import nimbus | ||
import nimbus.sources | ||
import nimbus.sinks | ||
import nimbus.transformers | ||
import numpy as np | ||
|
||
sync_frame = np.array( | ||
[ | ||
-1, | ||
-1, | ||
1, | ||
1, | ||
-1, | ||
-1, | ||
1, | ||
1, | ||
-1, | ||
-1, | ||
1, | ||
1, | ||
-1, | ||
-1, | ||
1, | ||
1, | ||
-1, | ||
-1, | ||
1, | ||
1, | ||
-1, | ||
-1, | ||
1, | ||
1, | ||
-1, | ||
-1, | ||
1, | ||
1, | ||
-1, | ||
-1, | ||
-1, | ||
-1, | ||
-1, | ||
-1, | ||
-1, | ||
-1, | ||
] | ||
) | ||
wave_source = nimbus.sources.Wave("examples/10080101_16bit.wav", buffer_size=5512) | ||
sdl_sink = nimbus.sinks.SDL(width=2080, height=1200) | ||
|
||
pipeline = nimbus.Pipeline( | ||
wave_source, | ||
[ | ||
nimbus.transformers.Caster(np.float32), | ||
nimbus.transformers.Hilbert(), | ||
nimbus.transformers.Caster(np.float32), | ||
nimbus.transformers.Tee(nimbus.sinks.Audio()), | ||
nimbus.transformers.Resample(sample_rate=4160), | ||
nimbus.transformers.Apt_Sync(sync_frame), | ||
nimbus.transformers.Caster(np.uint8), | ||
], | ||
sdl_sink, | ||
) | ||
pipeline.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
from .image import * | ||
from .audio import * | ||
from .iq import * | ||
from .sdl import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import numpy as np | ||
from PIL import Image as pil | ||
from nimbus import Samples | ||
import sdl2.ext | ||
import sdl2.ext.pixelaccess | ||
|
||
|
||
class SDL: | ||
def __init__(self, width: int, height: int): | ||
sdl2.ext.init() | ||
self.window = sdl2.ext.Window("Real Time Window", size=(width, height)) | ||
self.pixels = sdl2.ext.pixelaccess.pixels2d(self.window.get_surface()) | ||
self.window.show() | ||
self.row = 0 | ||
self.width = width | ||
self.height = height | ||
|
||
def execute(self, signal: Samples): | ||
if not signal.data.dtype == np.uint8: | ||
raise ValueError(f"SDL Sink requires np.uint8 signal: {signal.data.dtype}") | ||
|
||
for col in range(self.width): | ||
if col >= signal.data.size: | ||
self.pixels[col][self.row] = 0 | ||
else: | ||
lum = signal.data[col] | ||
self.pixels[col][self.row] = lum << 16 | lum << 8 | lum | ||
|
||
self.row += 1 | ||
self.row = self.row % self.height | ||
|
||
self.window.refresh() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters