Questions about produces audio files from a given sheet music (coding)

• Mar 15, 2020 - 14:03

For some reason, I want to separate MS's function of converting scores into sound files from the software,and I found some problems while looking at the code:
1. I searched rendermidi.cpp for the method which turn score into MIDI file, and I think I did find one called renderMidi(line 2489). However, I don't know what "chunk" "tick" means. I track their definition but still confused. Is "tick" a time unit? And what is "chunk" actually mean?

  1. As far as I know, a MIDI file is essentially a file consisting of a string of hexadecimal digits, but In renderMidi, I didn't find a method transfer notes into hexadecimal digits. Did I mis-understand something?

  2. It seems that "playevents" and "eventmap" are the key things in the conversion process, but I don't understand them at all... How exactly do they play a role in the conversion process?

  3. In rendermidi.cpp, an EventMap type variable named "events" is used a lot, but I can't find the declaration of the EventMap class. On line 2549 "evnets" also called a method of the EventMap class, and I couldn't see how this method was actually implemented. In fact, there are many such classes without declaration in the source code. I want to know how these classes can be used?


Comments

Reg 4. See synthesizer/event.h

class EventMap : public std::multimap<int, NPlayEvent> {
      int _highestChannel = 15;
   public:
      void fixupMIDI();
      void registerChannel(int c) { if (c > _highestChannel) _highestChannel = c; }
      };

PlayEvent is there too, might answer your point 3.

Tick refers to the position in time, expressed as a fraction (eg, beat 3 in a 4/4 measure is tick 3/4. A chunk is, as far as I know, a way of breaking the score up into sections so we only need to recalculate things for the portion that has changed, it's pretty arbitrary I believe.

Beyond that, you're getting deep enough in the specifics of the MIDI rendering that I'm not much use, but I do have to ask what your actual goal is, chances are good there is a way of achieving it that doesn't require whatever it is you are trying to do. There's also a decent chance that whatever is you are trying won't be able to work.

In reply to by Marc Sabatella

I am studying music pattern analysis. Specifically, I want to start with music scores, so I need to convert the music scores into sound files (MP3, MIDI, etc.) and then perform acoustic analysis on these files. Because MuseScore has such a function, I want to try to separate this function. However, I still don't understand some details. Does MuseSocre divide the entire score into chunks and then process each chunk? What role does EventMap play in the whole process? How is the converted MIDI file exported?

You wrote:
I need to convert the music scores into sound files (MP3, MIDI, etc.) and then perform acoustic analysis on these files.

OK, so... MuseScore is a scorewriting app.
It can notate music like this:
C_major_scale.png
Here's the MuseScore notation file: C_major_scale.mscz

It can convert to audio: C_major_scale.zip ...Please re-name ".zip" to ".mp3" to play.
(WAV, MP3, FLAC, OGG are available)
C_major_scale_waveform.png
(The C major scale waveform picture is from Audacity)

It can export MIDI: C_major_scale.mid
MIDI is not an audio file but rather a set of instructions for a machine (i.e., a music synthesizer) to play "note events" at designated times:
C_major_scale_MIDI_events.png
(The C major scale event list is from Anvil Studio)

The specific type of analysis will determine an appropriate format.

Do you still have an unanswered question? Please log in first to post your question.