Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: pure tone generation and output to speaker

  1. #1
    Junior Member
    Join Date
    Jan 2021
    Posts
    3

    pure tone generation and output to speaker

    Hey folks,

    my goal is to use a Teensy 4.0 to generate simultanious one to three (maybe more if achievable) pure tones and output these to an speaker.
    There should be three switches to turning the tones on/off and potentiometers to control the tone height.

    Maybe later i will add a display via SPI to show the the states and (k)Hz for each tone.

    But ... first of all. Is the Teensy capable to generate three (or more) tones and output these combined to one speaker?

    Thank you in advance for your time!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,226
    Yes, Teensy 4.0 can certainly generate 3 sine waves and mix them in software. You would use the audio library with 3 instance of the waveform synth, and a mixer to combine them.

    Getting the signal output to a speaker requires additional hardware. The best way would use the audio shield and an amplifier.

    Teensy 4.0 also has an output called MQS (medium quality sound) which creates sequences of pulses. You can buffer those with transistors and drive a speaker, or perhaps drive a very small speaker if done carefully with an extra resistor and capacitor in series. MQS sounds pretty good for casual listening, but because it's made with digital output pulses, it's a compromise in quality.

    The audio shield of other audio DAC gives the best output signal.

  3. #3
    Junior Member
    Join Date
    Jan 2021
    Posts
    3
    Hey Paul,

    thank you for your suggestions/explanations.

    Perhaps I should describe in more detail what I have in mind.

    I want to stick a mirror on the speaker, which will deflect the light beam of a laser pointer onto a wall (or the ceiling, depending on how you point the laser).

    Primarily, I want my children to play around with it a bit and maybe they will want to learn a bit more about sound waves, light and/or electronics.
    But I also want to finally give the Teensy, which has been living on my desk for far too long, a task.
    Based on the different frequencies or maybe even the voice (via mic) you can draw some nice figures.

    I think that even if the quality of the MQS is sufficient, I will probably go for the Audio Shield for the sake of simplicity. (Mic/SDCard)

    In another thread, you recommended the LM4871 to a user. This is already available on a small board with the corresponding caps and resistors.
    Unfortunately I have little knowledge of the audio world ... but would this amp be enough to drive a 4ohm/20w speaker.
    What would happen if i used an 8ohm speaker?

    with every new buzzword comes a thousand new questions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •