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

Thread: Use teensy to create engine sound generator

  1. #1
    Junior Member
    Join Date
    May 2018
    Posts
    9

    Use teensy to create engine sound generator

    Hi all,

    I am now working on a sound project which needs to use teensy 3.2 to create some "noise" for the quiet electrical engine.

    This project has a few requirements :

    1. standby, wake-up, sleep modes
    2. sound types control (able to switch among different kinds of engine sound)
    3. idling, forward, reversing three phases
    4. in forward phase, when start to accelerate, the engine sound will increase its volume and frequency like a real car engine sound performance
    5. brake sound

    In the last two weeks, I tried to study teensy 3.2 and started programming. Requirement 1, 2, 3, 5 all can work already. However, I don't know how to solve requirement 4 since I didn't figure out how to change source audio frequency. In the previous demonstration, I changed the source audio to waveform to represent engine sound so that the frequency can be easily changed. In my own opinion, the waveform sound is quite similar to engine sound but it seems my supervisor was not so satisfied with it.

    Is there any function in teensy 3.2 to change the audio frequency or anyone can give some suggestions to hit the requirement 4? Does there have similar teensy projects for me to study?

    Thank you !!

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,872
    Is this generating the audio from various oscillators/instruments or is it playing pre recorded clips? If you are synthesizing it is relatively straight forward to step things up or down but if you are playing prerecorded engine noises then you you are trying to change things so the clip runs faster while not changing pitch, which I do not believe is possible out of the box - the google term is normally pitch shift, though you would also be changing the playback speed.

  3. #3

  4. #4
    Junior Member
    Join Date
    May 2018
    Posts
    9
    Thanks for your reply! I expected there would have a reply notification so didn't notice that someone replied my post.
    Based on the requirements, I am supposed to play the prerecorded engine audio files stored inside SD card. I am using an analog knob to represent the speed signal from CAN bus. While the speed is increasing, the sound volume is increasing and become very sharp like a real engine performance. Currently I cannot figure out how to use this analog knob to control audio files.

  5. #5
    Junior Member
    Join Date
    May 2018
    Posts
    9
    Quote Originally Posted by GremlinWrangler View Post
    Is this generating the audio from various oscillators/instruments or is it playing pre recorded clips? If you are synthesizing it is relatively straight forward to step things up or down but if you are playing prerecorded engine noises then you you are trying to change things so the clip runs faster while not changing pitch, which I do not believe is possible out of the box - the google term is normally pitch shift, though you would also be changing the playback speed.
    Thanks for your reply! I expected there would have a reply notification so didn't notice that someone replied my post.
    Based on the requirements, I am supposed to play the prerecorded engine audio files stored inside SD card. I am using an analog knob to represent the speed signal from CAN bus. While the speed is increasing, the sound volume is increasing and become very sharp like a real engine performance. Currently I cannot figure out how to use this analog knob to control audio files.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,941
    Perhaps you can simply play the same small files repetitively, and reduce the time between playing to make the faster sound?

    Maybe play 2 or 3 simultaneously and mix them together?

    If the sound samples are small, it might be simplest to convert them to .c & .h files with wav2sketch and just put them into your program. Playing is much more efficient that way. Click File > Examples > Audio > SamplePlayer for example code, or check on Part 2-3 of the tutorial, starting on page 14, or just watch that part of the video if you'd rather see me & Alysia demo it.

  7. #7
    Junior Member
    Join Date
    May 2018
    Posts
    9
    Quote Originally Posted by PaulStoffregen View Post
    Perhaps you can simply play the same small files repetitively, and reduce the time between playing to make the faster sound?

    Maybe play 2 or 3 simultaneously and mix them together?

    If the sound samples are small, it might be simplest to convert them to .c & .h files with wav2sketch and just put them into your program. Playing is much more efficient that way. Click File > Examples > Audio > SamplePlayer for example code, or check on Part 2-3 of the tutorial, starting on page 14, or just watch that part of the video if you'd rather see me & Alysia demo it.
    Thanks for your suggestion! I will definitely try out the example.
    You workshop video with Alysia is very useful and informative, it gave me a great help during my last two weeks teensy study.

Posting Permissions

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