LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

piano

Solved!
Go to solution

falkpl wrote:

You could get fancy, and instead of using beep, you could create waveforms on the fly and feed it to a stream (buffer for audio output).  The waveforms would be made from the note frequency and various harmonics with defined decays.  There is probably some doccumentation of piano waveforms somewhere.

 


 

How would I change the sound from a beep, to sound more like a piano? Could you please explain further?
Cory K
0 Kudos
Message 11 of 39
(2,122 Views)

beep is   single tome (frequency) true sound form instruments are the sum of numerous harminics on the note and different decays.  I was never a good musician, but each instrument will be have unique characteristics on the harmonics and decays, this is why all instruments sound different and not like a synthetic pure tone.  using this approach to making each note, you can mix multiple notes into the same waveform for cords and even modulate the overall waveform and decay the amplitude so that note durations fade out after the note is played.  This can get very complex, but is probably what electrical pianos are doing.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 12 of 39
(2,115 Views)

I've just about finished up with Keyboard.VI  Version 1.0 Smiley Happy

The last thing that is holding me up is actually getting the files.

 

The easiest way to get music (besides .mp3) to work with is by downloading 'midi' files.

Somehow, I would need to convert the midi file into something I can actually use.
I would prefer if it was a text file or something easier to work with.

Any ideas?

Cory K
0 Kudos
Message 13 of 39
(2,107 Views)

OK, the piano part of the VI seems to be working great, provided I use a txt file as I described earlier.

The most common form of music I can find (that is easily compatible with a computer) is a 'MIDI' file.

Here is a detailed explination of how said file is formatted.

 

If you scroll to the very bottom of the page, it shows the Event Commands.
I'm thinking I could use 'Match Pattern' to find 'note on' and 'note off' events.
If I read the binary as strings, I can match:

1000****

1001****

for off and on respectively.

 

I'm assuming 'velocity' is the length of the note.

 

Does anyone have any advice on a better way to read the note and time?


These files contain MUCH more information about the song than  I am looking for, but parsing out the file should enable me to extract only the pieces I am looking for.

 

another question I had was:
The notes they list are 0-127.

A piano only has 88 keys.
How would I account for the difference in number of notes? Or does a piano not contain all of the listed octaves?

Cory K
0 Kudos
Message 14 of 39
(2,049 Views)

 

Hi Cory

This application is very suitable through MIDI protocol. Everything is already defined and implemented. You just need to find a way to interface LabVIEW with MIDI implementation already in use in most of computer sound cards.

Ricardo 

RKO
0 Kudos
Message 15 of 39
(2,046 Views)

I'm having a hard time opening a MIDI file in LabVIEW.

What exactly is it? A binary file?

 

I've tried both 'read text file' and 'read binary file', but get the following error:

 

And heres what the output looks like:

Message Edited by Cory K on 05-11-2009 12:30 PM
Cory K
Download All
0 Kudos
Message 16 of 39
(2,044 Views)

ROtake wrote:

 

Hi Cory

This application is very suitable through MIDI protocol. Everything is already defined and implemented. You just need to find a way to interface LabVIEW with MIDI implementation already in use in most of computer sound cards.

Ricardo 


Hi Ricardo,
Playing the file is more of a secondary goal for this VI.

The primary reason I am creating this VI is to show the keys being pressed on the piano as it is played in real-time.

Once I figure that out, I will worry about playing the file.

Cory K
0 Kudos
Message 17 of 39
(2,041 Views)

Cory K wrote:

I'm having a hard time opening a MIDI file in LabVIEW.

What exactly is it? A binary file?

 

I've tried both 'read text file' and 'read binary file', but get the following error:

 

 

And heres what the output looks like:


I'm pretty sure that error is expected - it's telling you that it successfully read to the end of the file, in the same way that it would if you had specified some very large number of bytes to read (which is essentially what you've done by leaving the length input unwired).  The file appears to be a binary file.  The difference between binary and text files is handling of end-of-line and maybe some other special characters which can be translated when dealing with text but should be left untouched when treated as binary data.  I haven't looked at the MIDI spec at all but my guess is that you'll want to create one or more clusters representing the MIDI data in a usable form, then break up the binary data you read from the file into appropriately sized chunks and typecast them to your clusters.
0 Kudos
Message 18 of 39
(2,023 Views)

I don't have much experience working with Binary.

How am I supposed to handle those characters, like the squares?
Is there a way to convert binary to ascii? Then I could figure out what I'm dealing with.

Cory K
0 Kudos
Message 19 of 39
(2,021 Views)

Cory,

 

All the bytes in both displays have already been converted to ASCII. Perhaps you want a display in hex.  Or maybe you want to display the non-alphanumeric characters in hex?

 

Just change the string indicator display format to Hex or to '\' Codes Display. Neither of these changes the underlying data, only how it looks in the indicator.

 

Lynn 

Message 20 of 39
(2,012 Views)