Go Down

Topic: Registering notes (Read 899 times) previous topic - next topic

jacobdensityxvolume

Johan -- I'm not really sure what a zero cross point is, could you explain to me more? Could you maybe message me a step by step of what hardware to get and how to implement all that stuff you explained into it?

Steve -- I was planning on using a MIDI track.  I was thinking of importing the notes as different short "songs" into an arduino mp3 player and coding, "when this frequency is registered, play this song on repeat" or something like that.  Any ideas? is this sort of importing possible?

slipstick

#16
Sep 26, 2017, 12:26 pm Last Edit: Sep 26, 2017, 12:35 pm by slipstick
MIDI suggests that you have another MIDI capable synthesiser or something playing the notes. If that is going to be an Arduino playing sounds via an mp3 player you probably don't need to convert the notes to MIDI at all.

But I'm not sure it will work very well. In my experience an mp3 player finding a "file" on an SD card and starting to play it takes quite a long time, maybe several seconds. There would be quite a delay between working out the note and hearing the sound which is probably not what you want for an instrument.

You might have more luck using something like https://moderndevice.com/product/fluxamasynth-shield/ or one of the other Arduino synthesisers to create the sounds.

Steve

DVDdoug

Quote
Johan -- I'm not really sure what a zero cross point is, could you explain to me more?
Do you know what a waveform is  A sine wave is positive half the time and negative half the time.   It crosses through zero twice per cycle...   A 100Hz sine wave crosses-through zero 200 times per second, once going-up and once going-down.  

But as we've discussed, real-world sounds are not sine waves.   If you what to see some real-world sound waves, open an audio file in Audacity (or any other audio editor).    You'll have to zoom way-way in to see the individual zero crossings.

Acoustic sound waves in the air don't go negative...  They are centered around atmospheric pressure and the air pressure increases & decreases around the ambient pressure...  If you are playing sound through a speaker the pressure goes up when the speaker moves-out and it goes down when the speaker moves-in.   A microphone doesn't pick-up the constant atmospheric pressure, it just picks-up the changes so the electrical signal coming-out goes positive & negative.

Quote
Steve -- I was planning on using a MIDI track.
That's a lot different from a tuba mouth piece...   Of course, the computer already knows all of the MIDI notes and if you're playing a MIDI file it knows the notes way in advance of when they are played.


Johan_Ha

Quote
Could you maybe message me a step by step of what hardware to get and how to implement all that stuff you explained into it?
Um, no. I don't know hardware. I've done this on a computer, fiddling around with a microphone, recording sound to Audacity, creating wav files, reading the files as binary data into a C/C++ program, which found the wave lengths using the method I described. I might be able to do the same stuff with an Arduino and some hardware, but I'd have to do a lot of research before I'd get it working. You do the research instead. :)
But I guess the list of hardware is not that long. An Arduino, a microphone, some flash memory (a micro sd card?)
Get Audacity! Play with it until you get an idea of what waves look like. Same pitch on different instruments creates very different wave shapes, but they all have the same wave length, if the pitch is the same. When you feel confident, do the following. In Audacity, record a continuous 1 channel (mono) sound of one tone of an instrument. Duplicate the produced wave. Focus on one spot and zoom in so that you see the wave lengths (repeating, almost similar wave forms). Take the time shift tool and shift one of the tracks one whole wave length. Zoom in to really see the individual samples to get the zero crossings exactly on top of each other. Now, if you'd subtract one wave from the other, almost nothing would be left, because the consecutive wave lengths seem to be almost identical. To do the subtraction, you have to invert one of the tracks. Then mix both tracks. You don't end in a flat line, because the wave lengths are not identical, but it's not far from flat. But if you didn't shift one track a whole wave length, but only to say the next zero crossing, which wasn't a full wave length, your mixed track wouldn't be flat at all. So, perfect wave length shift -> almost flat mix after inverting one track. Not a perfect wave length shift -> not at all flat mix. This very same procedure I did as a C/C++ program. What my program did was it squared each sample of the presumably flat mix. Then it added a bunch of squared samples. The sum told whether the mix was flat or not. Without squaring, the sum would have been near zero in any case, because there would might have been equally many samples above and below zero.
____________________
- One day my stepper motor driver works like a charm. No task is too big for it and I can do anything with it. Next day it refuses to work and even the tiniest motor blows its fuse. What's wrong with it?
- It's bipolar.

Grumpy_Mike

Quote
was planning on using a MIDI track.  I was thinking of importing the notes as different short "songs" into an arduino mp3 player and coding, "when this frequency is registered, play this song on repeat"
If you are using MIDI then their is no need to record anything.

Just send the MIDI sound generator with a note on and note off message. The message has three byte:-
1) Note on command ( a value of 0x90 )
2) The note number 0 to 127 - for example Middle C has a note number of 60
3) The note velocity 0 to 127 - a sort of loudness control.


Go Up