I am trying an AC piezo buzzer with mbed. I know how to generate a single tone sound using PWM and how to generate simple sounds by varying the PWM frequency (that is setting two arrays, one for frequencies and the other for durations and then changing the PWM frequency after the time defined in duration has elapsed).
My question is: how can I build the two arrays (frequencies and durations) from a generic sound I have in the form of a .mp3 or .wav or .mid file?
Is it possible to define the two arrays in a way to create some sort of voice?
Thanks.
I am trying an AC piezo buzzer with mbed. I know how to generate a single tone sound using PWM and how to generate simple sounds by varying the PWM frequency (that is setting two arrays, one for frequencies and the other for durations and then changing the PWM frequency after the time defined in duration has elapsed).
My question is: how can I build the two arrays (frequencies and durations) from a generic sound I have in the form of a .mp3 or .wav or .mid file?
Is it possible to define the two arrays in a way to create some sort of voice?
Thanks.
MIDI may be easiest. A MIDI sequence is already defined as a series of musical tones (freq and duration).
Converting an mp3 or wav file is more difficult. You may have to do some sort of FFT to extract the spectrum at regular intervals and generate the tones accordingly. That will only work when the sound consists of a series of single frequencies. The alternative is to take the sound amplitude samples in the wav file and use an analog output pin instead of PWM. Third option is to generate analog outputs using a high freq PWM output and lowpass filter that signal.
MIDI may be easiest. A MIDI sequence is already defined as a series of musical tones (freq and duration).
Converting an mp3 or wav file is more difficult. You may have to do some sort of FFT to extract the spectrum at regular intervals and generate the tones accordingly. That will only work when the sound consists of a series of single frequencies. The alternative is to take the sound amplitude samples in the wav file and use an analog output pin instead of PWM. Third option is to generate analog outputs using a high freq PWM output and lowpass filter that signal.
I dont have experience with midi, but google provides this link for converting midi to csv files: http://www.fourmilab.ch/webtools/midicsv/
Important Information for this Arm website
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.
I am trying an AC piezo buzzer with mbed. I know how to generate a single tone sound using PWM and how to generate simple sounds by varying the PWM frequency (that is setting two arrays, one for frequencies and the other for durations and then changing the PWM frequency after the time defined in duration has elapsed).
My question is: how can I build the two arrays (frequencies and durations) from a generic sound I have in the form of a .mp3 or .wav or .mid file?
Is it possible to define the two arrays in a way to create some sort of voice?
Thanks.