Piano Notes Wav Files
The examples below give a few different notes of a few different orchestral instruments. The examples are excerpted from The McGill University Master Samples collection, a fabulous set of CDs of instruments playing every note in their range, recorded in studio conditions. The examples below have been downsampled to 11 kHz mono, but the original data is much higher quality.
piano notes wav files
Each row in the following table consists of a single pitch, described both by its musical name (chroma+octave) and its nominal frequency (on the A440 tuning scale). Thethe different columns give that note played by some different instruments, where available. Some instruments cannot play some notes, so those cells are blank.
Note (freq)pianotrumpetfluteviolinG3 (196 Hz)piano-G3trumpet-G3 C4 (261 Hz)piano-C4trumpet-C4violin-C4flute-C4G4 (392 Hz)piano-G4trumpet-G4violin-G4flute-G4C5 (523 Hz)piano-C5trumpet-C5violin-C5flute-C5G5 (784 Hz)piano-G5trumpet-G5violin-G5flute-G5C6 (1046 Hz)piano-C6trumpet-C6violin-C6flute-C6G6 (1568 Hz)piano-G6 violin-G6flute-G6For more instrument samples, check out the University of Iowa Musical Instrument Samples (MIS).
To get the notes from the file, I think you need to do an FFT (Fast Fourier Transform) on the WAV file, but with only like 10ms of sound at a time. Then you find the highest peak on the FFT for that time frame, and move on to the next "frame" of 10ms, or whatever. You do the FFT again, and if the highest peak is a different frequency to the previous peak, then it will say it's a new note. To see how long the notes are, count the number of peaks within a certain threshold of each other and multiply them by the time you are using for each frame (10ms, etc)
If you want to get a 'real' piano sound, it's best to work with samples (hold them in memory if you don't want to keep them in the filesystem). If you just want a simple way of emitting accurate notes (which sound nothing like a real piano) then doing it programmatically is the way to go!
If you want to emulate a piano specifically you only have two options, one of which is to use samples and the other is physical modelling. Physical modelling requires some pretty advanced knowledge of DSP (filtering, convolution, etc.) and a piano would be a challenging instrument to tackle but it has been done by the likes of Pianoteq
On the subject of samples, to create a piano that is anywhere near a convincing analogue you would ideally require more than one sample per note for different velocities with crossfades between them but you can probably get away with using a sample over a limited range of notes to reduce the total number of samples.
this gives me this picture, which is the piano scale having eight notes in it. I want a way to isolate each note, so that I can then find it's frequency and figure out which note is being played. Once I have the notes isolated, I can take care of the rest.
Probably the easiest and most interesting thing to do is to calculate a spectrogram of your data, which is basically a plot of the spectra of short sections of your data, plotted against time. Do make the frequency scale logarithmic, since the frequencies of the keys on the piano are spaces exponentially. In Python, you could use the function specgram to calculate this, which is included with matplotlib. See for example this google image search for how this looks for different types of music. Also have a look at some computer programs that can play MP3/WAV and have visualization plugins, I remember that Winamp had a way of playing live spectrograms more than 10 years ago.
This is a fun exercise, but let me warn you if you want to use this technique to automatically transcribe the notes of some piece of music: this is a very hard problem, which has been studied by scientists for many years. One problem is for example that most instruments produce a lot of harmonics, which can confuse any algorithm to automatically find notes. And forget about any music with some human voices or percussion, since these produce a lot of wide-band noise (especially the letter 's' and hi-hats), making it almost impossible to recognize any other note.
If you want to get fancy, have a look at the Q-transform (see wikipedia and the papers referenced from there). You can consider this as a spectrogram, but with the bins along the frequency axis spaced logarithmically (e.g. bins for every half or quarter note on a piano scale). The advantage of this method over a standard spectrogram is that it has a constant number of frequency bins per note, while a linear frequency scale has few bins for the low notes, and too many for the high notes. I don't know if this is available for numpy, you might have to write the code yourself.
You've mentioned that you have a background in physics (which is helpful to know in the original question!) and you've indicated that you understand how to get the frequency and hence the note from a single piano tone using a FFT. What's missing then is moving from a function that is localized in both space and time, to one that varies in time. One kind of generalization is wavelet analysis, where the kernel is
The choice of g(t-u) gives different results depending on how you want to handle a signal that varies in time. Instead of giving you a spectral frequency, you get a two-dimensional map of spectral frequency and time. From this you'll be in a much better shape to extract notes from time-varying signals.
To put an update on this, here is the code we ended up going with. It uses a spectrogram averaged over the columns to figure out where the notes where, and from there using harmonics to figure out the main freqency of that note. Then using abjab to plot the notes on a sheet of music. Isn't perfect, but worked well for a major scale on the clarinet.
Press keys on the computer keyboard or click on the keys of the piano keyboardto play this virtual online piano simulator.Each key on the piano keyboard from C3 to C5 can be played by pressing an associated key on the computer keyboard.For example, C3 is played by pressing Tab while C#3 is played by pressing 1 and D3 is played by pressing Q and so on.Note that B4 is played by pressing the backslash key, while the Enter key plays C5.
The keys from the row A,S,D and the row Z,X,C are programmed to play white key chords for rich melodies.Moreover, with advanced options you can assign any user-defined chord or single note to any key of the computer keyboard.Tick the CHORD checkbox to indicate a chord on the piano keyboard and then check it off to create a custom-made chord button.This button will play your chord but it can also be configured to be associated with a computer keyboard key.
You can record anything played by this virtual piano keyboard and play it back at will.To start and stop recording check and uncheck the box RECORD. A playback button will appear automatically.You can have many playback buttons: each with its own recording. You can even play back more than one recording at the same time while making another recording to combine them.
You can generate a link that encodes all the chords from your buttons.For example, this link encodes all the possible three-note C major chords between C3 and C5: =48-52-55_48-52-67_48-55-64_48-64-67_52-55-60_52-55-72_52-60-67_52-67-72_55-60-64_55-64-72_60-64-67_64-67-72The online piano will be able to play all these chords after an appropriate button is clicked.
This is an online piano in the sense that it needs a live Internet connection to work.But there is an offline version available as a single HTML file that you can open in your browser without being connected to the Internet.Contact me directly if you are interested.
Load better soundsThe default sound files are optimized for speed of loading so that you can start playing the piano immediately without waiting for the sounds to load.However, this comes at the cost of reduced quality, which may be an issue when using external loudspeakers or headphones.Fortunately, you can optionally load better sounds if you need higher sound quality.
You might also be interested in my virtual guitarthat plays all the major chords, minor chords, and dominant sevenths chords. In fact, it can play any chords at all.But more importantly, the notes on the fretboard are visualized on a separate virtual piano keyboard which serves to explain how the guitar worksto those who already understand the piano.
I have the ambition to make it the most useful virtual piano online simulator in the world so I need to know what exactly my users expect when they play it.Please feel free to write any comments and remarks by using the email address displayed on theApronus.com homepage.
To put it simple, let's say I have a small WAV file sample of "I Like To Move It Move It" accappella from the song by "Reel 2 Real"... I'm actually trying to load this little wav file in ACID (in the MIDI interface I guess by replacing an existing MIDI sound perhaps?) and use the piano roll to draw a sequence playing the loaded sample sound instead of the default MIDI piano sound...
. . . . I'm actually trying to load this little wav file in ACID (in the MIDI interface I guess by replacing an existing MIDI sound perhaps? . . . . Basically, I want a piano roll playing a loaded WAV file instead of a selected MIDI sound . . . .
Wav and other audio formats are the final sound file that can be played in a player, MIDI files are not playable on their own, they contain instructions for a MIDI instrument or device to interpret and play.
Let me explain... in Cakewalk, from the default 128 MIDI sounds, it was possible to load a WAV file in memory and replace the actual sound for a given MIDI channel ... let's say Default MIDI sound on channel 1 is "Acoustic Grand Piano" ... well ... in cakewalk we were able to load a short WAV file in memory for channel 1, and then when we were playing / drawing notes on the piano roll, on channel 1, that WAV file was playing instead of the embedded sound of "Acoustic Grand Piano" ... just like "loading" a sound in a keyboard ! It was super fun and very usefull for megamix effects because by playing higher notes, the sound became higher and was playing faster... and by playing lower notes, the sound was playing lower and slower... that way we were using the piano roll as a sampler ! 041b061a72