diff options
-rw-r--r-- | simple_audio_python.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/simple_audio_python.py b/simple_audio_python.py new file mode 100644 index 0000000..99bc57d --- /dev/null +++ b/simple_audio_python.py @@ -0,0 +1,28 @@ +noise_output = wave.open('noise2.wav', 'w') +noise_output.setparams((2, 2, 44100, 0, 'NONE', 'not compressed')) + +values = [] + +for i in range(0, SAMPLE_LEN): + value = random.randint(-32767, 32767) + packed_value = struct.pack('h', value) + values.append(packed_value) + values.append(packed_value) + +value_str = ''.join(values) +noise_output.writeframes(value_str) + +noise_output.close() + +# ---------------- + +noise_output = wave.open('noise.wav', 'w') +noise_output.setparams((2, 2, 44100, 0, 'NONE', 'not compressed')) + +for i in range(0, SAMPLE_LEN): + value = random.randint(-32767, 32767) + packed_value = struct.pack('h', value) + noise_output.writeframes(packed_value) + noise_output.writeframes(packed_value) + +noise_output.close() |