mirror of
https://github.com/BlackLight/theremin.git
synced 2024-11-24 04:35:13 +01:00
New version
This commit is contained in:
parent
1ab65ddb7f
commit
2e3cc58948
3 changed files with 25 additions and 22 deletions
|
@ -27,6 +27,8 @@ def parse_args(args):
|
||||||
'{"portaudio", "jack", "coreaudio"}')
|
'{"portaudio", "jack", "coreaudio"}')
|
||||||
parser.add_argument('--channels', '-c', dest='channels', required=False, type=int, default=2,
|
parser.add_argument('--channels', '-c', dest='channels', required=False, type=int, default=2,
|
||||||
help='Number of audio channels (default: 2)')
|
help='Number of audio channels (default: 2)')
|
||||||
|
parser.add_argument('--rate', '-r', dest='sampling_rate', required=False, type=int, default=44100,
|
||||||
|
help='Sampling rate (default: 44100 Hz)')
|
||||||
parser.add_argument('--discrete', '-d', dest='discrete', required=False, action='store_true',
|
parser.add_argument('--discrete', '-d', dest='discrete', required=False, action='store_true',
|
||||||
help='If set then discrete notes will be generated instead of samples over a continuous ' +
|
help='If set then discrete notes will be generated instead of samples over a continuous ' +
|
||||||
'frequency space (default: false)')
|
'frequency space (default: false)')
|
||||||
|
@ -71,4 +73,4 @@ def main(args=None):
|
||||||
|
|
||||||
theremin(wave=opts.generator, audio_backend=opts.audio_backend, discrete=opts.discrete,
|
theremin(wave=opts.generator, audio_backend=opts.audio_backend, discrete=opts.discrete,
|
||||||
min_frequency=opts.min_frequency, max_frequency=opts.max_frequency, left_handed=opts.left_handed,
|
min_frequency=opts.min_frequency, max_frequency=opts.max_frequency, left_handed=opts.left_handed,
|
||||||
audio_output=opts.audio_output, channels=opts.channels)
|
audio_output=opts.audio_output, channels=opts.channels, sampling_rate=opts.sampling_rate)
|
||||||
|
|
|
@ -26,10 +26,11 @@ class Track:
|
||||||
|
|
||||||
|
|
||||||
class SoundProcessor:
|
class SoundProcessor:
|
||||||
def __init__(self, backend='portaudio', output=None, channels=2, discrete=False):
|
def __init__(self, sampling_rate=44100, backend='portaudio', output=None, channels=2, discrete=False):
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.discrete = discrete
|
self.discrete = discrete
|
||||||
self.server = Server(audio=self.backend, jackname='theremin', winhost='theremin', nchnls=channels)
|
self.sampling_rate = sampling_rate
|
||||||
|
self.server = Server(audio=self.backend, sr=sampling_rate, jackname='theremin', winhost='theremin', nchnls=channels)
|
||||||
self.audio_output = output or pa_get_default_output()
|
self.audio_output = output or pa_get_default_output()
|
||||||
self.server.setOutputDevice(self.audio_output)
|
self.server.setOutputDevice(self.audio_output)
|
||||||
self.tracks = []
|
self.tracks = []
|
||||||
|
|
|
@ -6,8 +6,8 @@ from .sound import SoundProcessor
|
||||||
|
|
||||||
|
|
||||||
def theremin(wave='SineLoop', audio_output=None, audio_backend='portaudio', channels=2, min_frequency=55,
|
def theremin(wave='SineLoop', audio_output=None, audio_backend='portaudio', channels=2, min_frequency=55,
|
||||||
max_frequency=10000, discrete=False, left_handed=False):
|
max_frequency=10000, sampling_rate=44100, discrete=False, left_handed=False):
|
||||||
dsp = SoundProcessor(output=audio_output, backend=audio_backend, channels=channels, discrete=discrete)
|
dsp = SoundProcessor(output=audio_output, backend=audio_backend, channels=channels, sampling_rate=sampling_rate, discrete=discrete)
|
||||||
dsp.start()
|
dsp.start()
|
||||||
|
|
||||||
assert hasattr(pyo, wave)
|
assert hasattr(pyo, wave)
|
||||||
|
|
Loading…
Reference in a new issue