I'm trying to build a sort of pedal [¹] in order to distort a varying input sound.
As I'm starting from the ground, I'm trying to generate in python a continuous sound and to vary the frequency of this sound as I slide a scrollbar (or a similar widget).
I've tried to use the tkSnack python library for the generation of the sound but it pauses between the generated tones. Instead of this behaviour, I want my script to play continuously the sound even if it is changing.
I've obtained a good result with my arduino thanks to the simple function tone() [²]. Probably the latency times are so low that the sound seems to be continuous. Is it possible to do a similar thing on my computer with python libraries on Linux?
Thanks to who is gonna help me! :)
[¹] http://en.wikipedia.org/wiki/Effects_pedal
[²] http://arduino.cc/en/Reference/Tone
Hello i used this formula last year to build a pedal
M = 2*D/(1-D);
x = (1+M)*(x)./(1+k*abs(x));
X = input Signal
D = distortion test some values like 0.1, 0.5, 0.9, etc and see the results.
This can be used in realtime inputline + python + pyaudio, the sound looks like one Overdrive ...
Update:
Real-Time primitive pedal distortion write in Python
#ederwander
import pyaudio
import numpy as np
import wave
chunk = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 8800
K=0
DISTORTION = 0.61
p = pyaudio.PyAudio()
stream = p.open(format = FORMAT,
channels = CHANNELS,
rate = RATE,
input = True,
output = True,
frames_per_buffer = chunk)
print "Eng Eder de Souza - ederwander"
print "Primitive Pedal"
while(True):
data = stream.read(chunk)
data = np.fromstring(data, dtype=np.int16)
M = 2*DISTORTION/(1-DISTORTION);
data = (1+M)*(data)/(1+K*abs(data));
data = np.array(data, dtype='int16')
signal = wave.struct.pack("%dh"%(len(data)), *list(data))
stream.write(signal)
stream.stop_stream()
stream.close()
p.terminate()
Change de Variable DISTORTION to see diferent results:
i changed a bit my source to make play recorded samples, i did Make some test, i get this audio: http://www.freesound.org/people/eriatarka/sounds/15753/ and then applied the formula described here, you can listen the changed file here: http://www.freesound.org/people/ederwander/sounds/146277/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With