diff options
author | bnewbold <bnewbold@robocracy.org> | 2011-08-14 19:48:06 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2011-08-14 19:48:06 -0400 |
commit | c794e2f48748aad7979447b1bfd9c1373d064615 (patch) | |
tree | 5e5f1f2af85d98f53c869adb3a7e2411b0c0a60b | |
parent | b1bce8be26ee4ab2e905703f0f1f14182e26c124 (diff) | |
download | solar_autonoma-master.tar.gz solar_autonoma-master.zip |
-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() |