def write_file(): channels = ((x for x in sound), ) write_wavefile('/tmp/test.wav', channels, len(sound), 1, 2, 22050)
def play_melody(volume, timbre, *sounds): print "Playing", sounds for sound in sounds: freq = tones.get(sound[0]) if freq: sound[0] = freq stream(volume * get_samples(timbre, *sound)) def cleanup(): p.terminate() print "PyAudio terminated." if __name__ == "__main__": if len(sys.argv) > 1: melodies = [] stream = lambda x: melodies.append(x) and x main() melodies = np.concatenate(melodies) channels = ((imap(float, np.nditer(melodies)), ) for c in range(2)) write_wavefile(channels) else: orig_stream = stream stream = stream.write main() orig_stream.stop_stream() orig_stream.close() atexit.register(cleanup)
from Sompyler.synthesizer.oscillator import CORE_PRIMITIVE_OSCILLATORS import numpy as np import matplotlib.pyplot as plt from sine2wav import write_wavefile cpo = CORE_PRIMITIVE_OSCILLATORS() iseq = np.arange(22050) noisegen = cpo['noise'] for i in (20, 100, 150, 300, 350, 700, 1400, 2800, 5600, 11200, 16500, 20000): print "Write noise file of " + str(i) + "Hz ..." r = noisegen(i, iseq) channels = (np.nditer(r), ) write_wavefile('/tmp/testb' + ('%05d' % i) + '.wav', channels, len(r), 1, 2, 22050) # plt.plot(iseq, r) # plt.show()
def write_file(sound, filename): print "Writing", filename normalize_amplitude(sound) channels = ((x for x in sound), ) write_wavefile(filename, channels, len(sound), 1, 2, 22050)
def write_file(fname): channels = ((x for x in sound),) write_wavefile(fname, channels, len(sound), 1, 2, 22050) print "Successfully written", fname, " – Please play with an appropriate command."