Sound "beep"
TexFly
Posts: 26
Hello,
What's the easiest and least memory consuming way of playing a simple sound?
Like BEEP!
I need to play few different alert sounds...not a 3D orchestra!
Thanks.
Tex
www.createandsolve.com
What's the easiest and least memory consuming way of playing a simple sound?
Like BEEP!
I need to play few different alert sounds...not a 3D orchestra!
Thanks.
Tex
www.createandsolve.com
Comments
There are objects like Freq Synth for synthesizing a pulse train of a particular frequency. That's a very simple technique that creates very simple rough tones (because of the pulses). If you want something smoother, you will need some kind of sine wave synthesizer which has also been done and takes more memory and processor usage than a simple pulse train. There's a WAV player in the OBEX for complex recorded sounds, but it takes more memory, mostly for the WAV file.
You decide what you want, look through the OBEX, and decide how much in the way of resources you are willing to devote to your alert sounds.
Ex. beep(1, 2500, 100)
Although the HSS code isn't "easy" to understand if your trying to understand the object...
The code to get it running IS easy to understand and get going.
The HSS sound system is a simple object that lets you create a very wide variety of sounds using the FX channels.
It is NOT wave data, it is sound generated on the fly from an audio engine, so it doesn't require large amounts of memory. http://www.andrewarsenault.com/hss/
I use it in my black box sequencer to generate all the sounds you hear in the videos at the project link.
http://forums.parallax.com/showthread.php?t=115258
T_Chap I like your method. Unfortunately it is missing the calcfrq function...
Would you publish that as well?
Thanks.
The minimum is a piezoelectric speaker that puts out a fraction of a watt and requires that you create the frequency within the Propeller.
But there are 'beeper' and 'buzzer' devices that look quite similar and just have to be toggled on and off. Some of these will drive directly from a Propeller pin as they are also a fraction of watt output, but others might require a 2N2222 transistor to switch them as they require more power and/or a higher voltage (+5, +6, or +12).
Finally there are real 8 ohm speakers with something like 5 watts output. A darlington transistor - like a TIP120 will drive one of these directly from a Propeller and may even require a resistor to limit current to 5 watts output. This is a real wake up beep. Admittedly, nothing is considered here to reshape the square wave or limit the harmonics, just make an attention getting noise. But after all, you requested minimal.
I have an 8-bit mono wav player in OBEX (and my website) that you can use with the wave files embedded in your app. But, this takes up a lot of memory...
I've got a simple MIDI player that should use less space:
http://forums.parallax.com/showthread.php?t=108673&highlight=sine
I've got a couple sine wave generators:
http://forums.parallax.com/showthread.php?t=98763&highlight=sine
http://forums.parallax.com/showthread.php?t=112389&highlight=sine
BTW: This new forums search is great! (this is the first nice thing I've said about the new forum)
T_Chap code works well and it uses minimum memory...so I'm going to try that.
Tex
A smooth sine-wave can be done by using DDS (digital direct synthesis).
delay_ms = time of "beep" in milliseconds
The pins 14 and 15 are my audio-pins, you should change this to your needs. If you have only mono audio, drop one of them.
Unfortunately i did'nt anything with Prop-Assembler, but on a 8051 i can do this job within 15bytes of machine-code