-
Notifications
You must be signed in to change notification settings - Fork 5
Add microphone/audio device input #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f7da90a
to
951fe02
Compare
951fe02
to
8a07a93
Compare
action='store_true', | ||
help='List all available audio input/output devices and exit', | ||
) | ||
argument_parser.add_argument('--enable-audio-input', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems redundant to enable audio and pick a device. I guess in the case of using defaults this might make sense. So perhaps the opposite works better: --audio-input OFF
or similar to disable it specifically
new_data_contiguous = np.ascontiguousarray(self.data) | ||
|
||
bytes_per_row = self.texture_size[0] * self._num_components * new_data_contiguous.itemsize | ||
if bytes_per_row % 256 != 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this be a constant here?
class ShadertoyChannelMusic(ShadertoyChannel): | ||
pass | ||
""" | ||
Represents a Shadertoy music input channel, updated to match the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be the ShadertoyChannelMicrophone
while a lot of code can be reused (and maybe inherited) for Music and Soundcloud - there will be differences in where the samples come from (streaming from file, streaming from network vs device).
So code will likely be shuffled around a bit when these get implemented.
import sounddevice as sd | ||
import sys | ||
|
||
# Set up command line argument parsing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this functionality is supported by the cli, we should just have a simple example that has the code as a string and show how the channel class can be setup manually.
settings["address_mode_w"] = wgpu.AddressMode.clamp_to_edge | ||
return settings | ||
|
||
# class ShadertoyChannelMusic(ShadertoyChannel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want to preserve the initial version you can try to add a commit before so it shows up in diff for this branch (we will squash merge). Otherwise this should be cleaned up before we can merge
hey @richinsley sorry this took a while. I left a few comments that need to be addressed and it would also be great to get CI working. It might required some additional library for the linux setup in the workflow. Looking forward to have this merged as I found some update propagation oversights that I will look into in a followup while working on keyboard input. So having another interactive channel working will be great. |
This adds an abstract audio device class with a sub-class that creates an audio device using the sounddevice package.
ShadertoyChannelMusic is implemented to pull the audio data from it's given audio device and generates the waveform and fft data.
infer_subclass detects ctype of 'mic' and creates the ShadertoyChannelMusic instance.
An example (shadertoy/examples/shadertoy_mic_input.py) was added that demonstrates how to select and add the audio device to the ShaderToy instance.
Changes from original PR (#45):