+ 1
How to make white noise in python??
3 Answers
+ 4
@Pardeep Please post it in Code Playground then link it here.
+ 3
# A stereo "White Noise" generator using STANDARD Python 2.5.2 or higher.
# This is for (PC)Linux(OS), (ONLY?), and was done purely for fun.
#
#
# (Original copyright, (C)2010, B.Walker, G0LCU.)
#
# DONATED TO LXF AS PUBLIC DOMAIN...
#
# Ensure the sound is enabled and the volume is turned up.
#
# Copy the file to the Lib folder/drawer/directory where Python resides,
# or where the modules reside, as "noise.py" without the quotes.
#
# Start the Python interpreter from a console/terminal window.
#
# For a quick way to run the noise generator just use at the ">>>" prompt:-
#
# >>> import noise[RETURN/ENTER]
#
# And away we go...
#
# This code is now Public Domain and you may do with it as you please...
#
# Coded on a(n) HP dual core notebook running PCLinuxOS 2009 and
# Python 2.5.2 for Linux; also tested on Knoppix 5.1.1 and Python 2.5.2
# and Debian 6.0.0 and Python 2.6.6...
#
# Connect an oscilloscope to the earphone socket(s) to see the noise
# waveform(s) being generated.
# Import any modules...
import os
import random
# Clear a terminal window ready to run this program.
print os.system("clear"),chr(13)," ",chr(13),
# The program proper...
def main():
# Make all variables global, a quirk of mine... :)
global noise
global value
global select
global count
global amplitudestring
global amplitude
# The INITIAL default values.
select="G0LCU."
value=0
noise=chr(value)
count=0
amplitudestring="64"
amplitude=64
# A continuous loop to re-generate noise as required...
while 1:
# Set up a basic user window.
print os.system("clear"),chr(13)," ",chr(13),
print
print "Simple Noise Generator using STANDARD Python 2.5.2"
print "for PCLinuxOS 2009, issued as Public Domain to LXF."
print
print "(Original copyright, (C)2010, B.Walker, G0LCU.)"
print
# Set amplitude level from 0 to 64 unclusive.
amplitudestring=raw_input("Enter amplitude level, 1 to 64
0
Thanks!