I mentioned earlier about the code detecting multiples of the expected frequencies, and apparently these are caused by the harmonics tied with sounds produced by the guitar and the human voice among other intruments, both of which I used to test the code below. You'll see a lot of his computation in the code below, but I tweaked it a bit in an effort to get more favorable results. I simplified benjaminoutran's code and incorporated it into the existing code I had that was based from aldonaletto's code in this thread ( ). Through benjaminoutran in this post ( ), I found that you now needed to set the output channel of your Audio Source through an Audio Mixer to work around this problem, and you get the option of muting it through its Volume propoerty. It was through this that I realized that muting the AudioSource also mutes the input from the Microphone, blocking any possible output from AnalyzeSound (). I had to do another pitch detection thing for another app and so I needed to look for solutions to the problems the new system gave.Ī huge problem was that the Microphone didn't work anymore. It's been a while and I recently upgraded to Unity 5, which messed up a lot of my work before. I'm under a lot of pressure to finish this so I really thank you in advance. Is there a way to make this code do that? (I'm a beginner at Unity, sorry.)Īny help with this is deeply appreciated. As I said, this is a real-time implementation and that isn't exactly what I need as I want to record audio, then compute on the produced track. Is there a better method of getting an audio track's fundamental frequency? I noticed that this does calculations in real-time, so I'm thinking that GetSpectrumData() doesn't take into account the whole track itself when computing spectrum data.ģ. Is there any way that I can improve the precision of the returned frequencies? I've tried playing with sample rates, bin lengths, loudness, etc, but it's mostly the same problem.Ģ. I'm no expert at music, but I'm pretty sure it's playing notes in the correct order and their pitches are pretty accurate.ġ. To play notes, I'm using sonicviz's Unity implementation of the MIDI C#Synth Project from CodePlex, whose link can be found here: I can say this because some notes are okay and stable as they always return the same thing at the expected frequencies. Probable frequencies are the ones that are most likely correct when compared to the nearest notes. I say probable because the frequencies sometimes spike up to 800Hz and above or stay as low as 90Hz when I play notes with frequencies that should be in the 200's. ![]() One, because it sometimes returns different frequencies when I play the same note, and two, because the probable frequencies don't change their range (of around 230 to 430Hz) even if I change the octave completely. I've got it all up and running, I'm positive that my laptop detects audio input as the displayed frequencies change, and it somehow works as said frequencies change when I play different notes, but I'm not sure if it's accurate at all. ![]() Links are the following:įundamental Frequencies and Detecting Notes: Right now, I'm using Kaapine's tutorials on input using Microphone, collecting spectrum data using AudioSource.GetSpectrumData(), and further calculating fundamental frequency given other values. Essentially, the goal is to record vocal input through the microphone and make it a temporary audio track, collect spectrum data from this track by Fast Fourier Transform (FFT), and get the fundamental frequency from the spectrum data. I'm currently making an application that displays a note that corresponds to what a user sings into their device.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |