You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I would like to generate 1 khz sine wave which I can do fine with this code
importmath#import needed modulesimportpyaudio#sudo apt-get install python-pyaudio#List I/O Audio ports to use#Input Device id 0 - Microsoft Sound Mapper - Input#Input Device id 1 - Line 1 (Virtual Audio Cable)#Input Device id 2 - Line 4 (Virtual Audio Cable)#Input Device id 3 - Line In (Realtek High Definitio#Input Device id 4 - Line 2 (Virtual Audio Cable)#Input Device id 5 - Microphone (Realtek High Defini#Input Device id 6 - Line 3 (Virtual Audio Cable)#Output Device id 7 - Microsoft Sound Mapper - Output#Output Device id 8 - Speakers (Realtek High Definiti#Output Device id 9 - Line 1 (Virtual Audio Cable)#Output Device id 10 - Line 3 (Virtual Audio Cable)#Output Device id 11 - Line 2 (Virtual Audio Cable)#Output Device id 12 - Line 4 (Virtual Audio Cable)PyAudio=pyaudio.PyAudio#initialize pyaudio#See https://en.wikipedia.org/wiki/Bit_rate#AudioBITRATE=192000#number of frames per second/frameset. FREQUENCY=1000#Hz, waves per second, 261.63=C4-note.LENGTH=10#seconds to play soundifFREQUENCY>BITRATE:
BITRATE=FREQUENCY+100NUMBEROFFRAMES=int(BITRATE*LENGTH)
RESTFRAMES=NUMBEROFFRAMES%BITRATEWAVEDATA=''#generating wawesforxinxrange(NUMBEROFFRAMES):
WAVEDATA=WAVEDATA+chr(int(math.sin(x/((BITRATE/FREQUENCY)/math.pi))*127+128))
forxinxrange(RESTFRAMES):
WAVEDATA=WAVEDATA+chr(128)
p=PyAudio()
#Open Device for streamingstream=p.open(format=p.get_format_from_width(1),
channels=1,
rate=BITRATE,
output=True,
output_device_index=9)
stream.write(WAVEDATA)
stream.stop_stream()
stream.close()
p.terminate()
the problem is that audio is plattered all over 192khz
what I would like to do is move this to 19khz and cut all the junk out of the signal so it would look more like this:
I thought I could acomplish this with audiogen and then play generated samples using pyaudio (since you added bandpass filter) but I don't realy know how would I do this
Thanks for Anwsering and Best Regards
The text was updated successfully, but these errors were encountered:
Hi I would like to generate 1 khz sine wave which I can do fine with this code
the problem is that audio is plattered all over 192khz
what I would like to do is move this to 19khz and cut all the junk out of the signal so it would look more like this:
I thought I could acomplish this with audiogen and then play generated samples using pyaudio (since you added bandpass filter) but I don't realy know how would I do this
Thanks for Anwsering and Best Regards
The text was updated successfully, but these errors were encountered: