Playing solid sine wave
Author |
Message |
DtY
|
Posted: Fri Jul 24, 2009 9:37 pm Post subject: Playing solid sine wave |
|
|
Is there a standard library in python (or using pygame) a way to play a solid sine wave, needs to work on both windows and linux. (If there are ways to do it on both that only work on the one, that works too, I can write a module to wrap it)
If not, is there a library I can download to do that?
And not too necessary, but if the above exists, is there a way to make it play a few frequencies on top of each other?
Thank you |
|
|
|
|
|
Sponsor Sponsor
|
|
|
The_Bean
|
Posted: Sat Jul 25, 2009 9:38 am Post subject: Re: Playing solid sine wave |
|
|
If you are talking about drawing multiple sine waves that are 'rolling' with different amplitudes on top of each other, pyGame should be able to do it.
Use the built in draw methods, 0 line thickness makes it filled in.
PyGame works on both unix and windows systems, so your fine there. |
|
|
|
|
|
DtY
|
Posted: Sat Jul 25, 2009 11:38 am Post subject: RE:Playing solid sine wave |
|
|
No, I mean playing a sine wave. "on top of each other" I mean mixed |
|
|
|
|
|
apomb
|
Posted: Sat Jul 25, 2009 3:43 pm Post subject: RE:Playing solid sine wave |
|
|
you'd have to know the math to do that, and just draw them accordingly. |
|
|
|
|
|
DtY
|
Posted: Sat Jul 25, 2009 4:22 pm Post subject: Re: RE:Playing solid sine wave |
|
|
apomb @ Sat Jul 25, 2009 3:43 pm wrote: you'd have to know the math to do that, and just draw them accordingly.
I'm not trying to draw anything.
If it helps, I'm looking for a way in python to do exactly what Turing's Music.Sound() does. (Except possibly mixing multiple frequencies. |
|
|
|
|
|
apomb
|
Posted: Sat Jul 25, 2009 5:32 pm Post subject: RE:Playing solid sine wave |
|
|
ooh actually play the sounds. sorry, i misunderstood. I'm unaware of how to do that. |
|
|
|
|
|
Zeroth
|
Posted: Wed Jul 29, 2009 10:21 am Post subject: Re: Playing solid sine wave |
|
|
Have you looked at Pygame's mixer module? You can actually create a Sound object from a readable buffer object. So you just fill your buffer with the sine wave values, then play the sound. You can actually play different sounds on different channels even(max 2 channels). Just remember, its looking for 22k samples per second(with the default frequency for the mixer)... so it can be quite a big buffer.
http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.Sound |
|
|
|
|
|
DtY
|
Posted: Wed Jul 29, 2009 11:35 am Post subject: Re: Playing solid sine wave |
|
|
Zeroth @ Wed Jul 29, 2009 10:21 am wrote: Have you looked at Pygame's mixer module? You can actually create a Sound object from a readable buffer object. So you just fill your buffer with the sine wave values, then play the sound. You can actually play different sounds on different channels even(max 2 channels). Just remember, its looking for 22k samples per second(with the default frequency for the mixer)... so it can be quite a big buffer.
http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.Sound
That could help! Thank you.
I can't imagine it going very fast in python, but I'll see how easy the C API is to use, and see if I can use that.
I'll post the code if I do get it to work
Thanks again
[edit] Is there any way to change the sampling rate? I don't need to play very high frequencies, and they don't need to sound the greatest, so a lower sampling frequency is probably best. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Zeroth
|
|
|
|
|
|
|