Playing part of a MIDI track

Playing part of a MIDI track

Post by Andre » Wed, 16 Nov 2005 03:21:18


I am interested in writing a program that will
test the users ability to identify a song based
upon playback of a certain number of notes in a
MIDI file. Sort of like Name that Tune.

I will be using type 0 MIDI files to start.

I have looked at the MIDI spec briefly, but it's
a bit confusing.

I should be able to get the complete MIDI file into a byte array.

I figure I can use the standard MIDI header.

Now say I want to copy a section of the track data
that contains the note information.

How would I identify the start of a MIDI event
so that I know that I'm starting at a "good" location?

Thanks,

Andrew
 
 
 

Playing part of a MIDI track

Post by NoBy » Wed, 16 Nov 2005 05:09:51

Andrew pisze w



Not necessary. You may parse midifile on the fly.


You have to use midifile header ;)


How do you determine this selection?


If you don't know event position in midifile you should parse
midifile from its or track begin. You may try scan midifile from
"inside" but that might be a bit complicated.

--
NoBy MD5: 486cf5eee849c8de7bb630e4aaa8b761

 
 
 

Playing part of a MIDI track

Post by Andre » Wed, 16 Nov 2005 14:10:03


It would just be random.

For example, the random number generator might
choose the numbers 25 and 16.

Therefore, the selection would start at the 25th
note and be 16 notes long.

How do I determine where the 25th note starts?

Andrew
 
 
 

Playing part of a MIDI track

Post by NoBy » Wed, 16 Nov 2005 17:22:35

Andrew pisze w



By read first 24 notes.

--
NoBy MD5: 486cf5eee849c8de7bb630e4aaa8b761
 
 
 

Playing part of a MIDI track

Post by Harald Sch » Wed, 16 Nov 2005 20:16:36

Hello,

Andrew schrieb:

Better start out with an appropriate data structure.
If you're using C++, use the STL and its containers.
You could e.g. use a linked list in which every entry is a note or some
other MIDI data. For choosing an entry randomly, generate a random
number and walk through the list.
Basically, if you've got a good data structure, it makes the
conception of algorithms easier.

Harald
 
 
 

Playing part of a MIDI track

Post by akd_ec » Thu, 17 Nov 2005 00:00:52

Hi Andrew,

In a midi file, the notes are separated by their respective relative
event times. These event times have a specific format called as
variable lenght format.
Specifi technique can tell u if u have finished reading variable length
quantity and wheather u are now at the start of the event. However this
is possible
only if u begin at the start of the variable length quantity.
Hence if you start somewhere from middle of the midi file, I feel, it
would not be possible for u to locate an event/note.

People please correct me if I am wrong anywhere.

I am also working on the code development of G-MIDI from scratch. I
have completed the parsing of the code keeping the synthesiser as a
dummy block
which just outputs 0 data. I have to start working on wave form
synthesis now, however I could not find any documentation on the net
and I dont know how to begin.
Could some one help me with any links / documentation / code on
waveform synthesis for GMIDI gving a detailed method of parsing the
data from DLS and its synthesis.

I would be really grateful for any help.

Thanks and Regards,
Anoop Deoras
INDIA
 
 
 

Playing part of a MIDI track

Post by Andre » Thu, 17 Nov 2005 00:51:19


I could do that if the events were all the same
size but as I understand it the first byte is a
time-stamp of variable length.

So I'm still not sure how to identify the start
of a MIDI event?

Andrew
 
 
 

Playing part of a MIDI track

Post by Andre » Thu, 17 Nov 2005 00:53:14


Yes. What's the technique I could use?

Thanks,

Andrew
 
 
 

Playing part of a MIDI track

Post by Andre » Thu, 17 Nov 2005 01:09:05


Good point.

I'm using Java and there is a MIDI interface I could
probably use to get the MIDI events but I'm still
trying to understand how the MIDI file format works
with respect to identifying that start of an event. :)

Andrew
 
 
 

Playing part of a MIDI track

Post by akd_ec » Thu, 17 Nov 2005 01:11:19

refer to the specifications and u will know how to read any variable
quantity.
say for ex ur midi file has following info:

[variable length: Delta Time a] [Event a] [variable length: Delta
Time b] [Event b] [variable length: Delta Time c] [Event c] ...

start reading from start... ur Read_Variable length will fetch u the
Delta Time a.. now u will be at the start of event a
read that and file pointer will be at the start of variable length
Delat Time b....

I guess that helps
 
 
 

Playing part of a MIDI track

Post by Joe » Thu, 17 Nov 2005 21:04:55

In article <Xtnef.1767$ XXXX@XXXXX.COM >,




There is no identifier. I think you really have to read the file from
the beginning of the track. As you say, each event is a variable length,
so you have to read the file sequentially until you get to where you
want to be. The only event where you can really 'know' where it starts
is the first one in the track (after the track header). All the rest
have to be calculated based on the size of the previous event. Once you
understand the format it all makes sense but it is a bit confusing at
first.

Peter
 
 
 

Playing part of a MIDI track

Post by Harald Sch » Fri, 18 Nov 2005 09:17:28

Hello,

Andrew schrieb:

The basics are here: http://www.yqcomputer.com/ ~jglatt/tech/midifile.htm

For identifying the start of an event, you have to locate
the one header and probably multiple track chunks. Within
the track chunks, the events are listed sequentially with
their delta times. Delta times and events are of vaiable length,
depending on the content - see
http://www.yqcomputer.com/ ~jglatt/tech/midifile/vari.htm and
http://www.yqcomputer.com/ ~jglatt/tech/midifile/evts.htm .

Harald