View Full Version : [queued] Notes to Waves

05-11-2020, 11:39 AM

Here is a fun project I would like to share with the community. It is a basic 3 oscillators synth plus an input follower stage. You can plug in a microphone and convert dynamics and notes of an acoustic instrument into frequency and envelope, and then trigger the synth oscillators and effects.
This was made possible thanks to the noteFreq object developed by Duff. This object uses the YIN algorithm to guess the notes frequency (almost) in realtime. Dynamics are analysed with the rms object.
Filtering the signal is important to get better frequency analysis, but also to limit the feedback when playing on stage.

Limitation is latency. It is possible to reduce latency with high pitch instruments (thank you Duff for your guidance). I doubt we can get good results with low pitch instrument like cellos, double bass, tenor and baryton sax... But it works pretty well with "treble key" instruments like the flute, the violin, the trumpet...

I am still trying to reduce latency. If someone has any suggestion, I would be very happy to exchange ideas.
Here are a few pics and a video.

Emmanuel (France)




05-11-2020, 11:57 AM
5 times faster .... That's good news. I am going to investigate this right now !

05-11-2020, 12:04 PM
Great project! Would you be willing to share your code?

For faster guessing of frequencies have a look at my project here:

With FFT my tuner can estimate frequencies ~5x faster than with Yin.

I use the lowest FFT freq found nearest to Yin freq if found, so if rate is so high that Yin doesn't find a freq FFT still does. Average in case both find a freq close to each other. You can find my code in the linked thread.

05-11-2020, 12:45 PM
Thanks for your suggestion.
Yes I will share the code. I have to reformat it or you won't be able to understand it. Basically, i have adapted the examples coming with the audio library. Nothing new !

05-20-2020, 12:21 AM
Ok, I am just interested in some detail such as how often do you read notefreqs result, do you adjust gain permanently for a steady level, does EQ the input help reducing wrong estimates, what probability and threshold settings do you use, and is there anything else I can do...?

I guess buffer size in notefreq.h is the most important setting: what size did you prefer for flute?

05-20-2020, 06:47 AM
I publish the main code here

I call notefreq1.available() and rms1.available() without any delay or timer. Peak object also works well.
notefreq threshold : 0.3
I use a pot adjust input level. No code, just a pot.

important : edit AUDIO_GUITARTUNER_BLOCKS parameter in the analyze_notefreq.h file. Try lower values (4 or 6 or 8). This is the most efficient way to reduce latency (but you may have problem with low pitch instruments).
Filtering is important. It reduces feedback when playing live. It also helps with freq detection. I use the builtin 5 bands eq of the SGTL 5000 audio shield.


05-20-2020, 03:48 PM
Many thanks, this helps a lot.

When mentioning that FFT was faster than Yin I used default value for AUDIO_GUITARTUNER_BLOCKS. Did you try if adding FFT helps to improve speed?

05-20-2020, 04:07 PM
Yes I made some tests. FFT is faster, but it is not optimised for complex sounds. For instance, for the flute FFT is OK. But results are totally wrong for the trumpet. It is always about compromises...

05-20-2020, 04:17 PM
What does your code mean:

waveformMod1.frequency(freq * osc1_oct * transpose);
waveformMod2.frequency(freq * osc2_oct * detune);
waveformMod3.frequency(freq * osc3_oct);
How does "transpose", "detune", "osc_oct" modify the result of notefreq?

05-20-2020, 04:32 PM
For instance, I have a pot that returns 0.25 ; 0.5 ; 1 ; 2 ; 4 ... This result is stored in osc1_oct variable. The multiplication fréquence * osc1_oct allows you to shift the frequency of +/- n octaves.
"transpose" is used to shift the frequency within a range of a 5th.
"detune" is used to shift the frequency within a range of 1 semitone.
Have a look there : https://www.youtube.com/watch?v=UJcZxyB5rVc&t=6s
There is on episode dealing with detune.

05-21-2020, 08:51 PM
Many thanks, I will try to improve my code with your suggestions!