fbpx
  Monday, 24 May 2021
  22 Replies
  5K Visits
1
Votes
Undo
  Subscribe
I am writing a piece of software to easily change instrumentation in a midi file.

I've come to the point where I am nearing the end, and now an important question comes up: I'm adding in bank switching support, meaning that as long as the playback device supports it, I will allow changing to any available instrument banks or drum kits. This is "easy" if there is only one instrument in a track, it gets more complicated when a track contains multiple instruments.

It gets potentially chaotic when drum kits are involved. Are midi files allowed to rapidly switch drum kits?

For example, let's say I have a GM file using "Standard Set" with a drum, a cymbal, and a side stick. All percussion is in a single track.
Let's then say I change only the cymbal to "Room Set", and only the drum to "Power Set". This will require inserting a kit (program) change before each of the instruments whenever they appear after another instrument, potentially leading to hundreds of kit changes over the course of the song.

Will midi allow this? I imagine it is technically correct. Would it play back properly on hardware? Would it matter if this was done in a GM vs GS vs XG file?
2 years ago
·
#9093
0
Votes
Undo
After many years of creating and analysing MIDI files, I've never come across this practice, i.e. switching kits just to implement a single hit or two.
What I have come across, which seems to be the normal way to do things, is to implement, e.g. the standard set on channel 10 and then a second set, e.g. room kit on another channel, usually 11. Using two channels is not uncommon, but I've never seen three channels used this way, although I suppose it's possible.

Take a look at the GM2 specification and it shows you how to do this with the GM2 kits.
But I suspect you already know this.

It's perfectly feasible to switch kits as often as you like in the MIDI file.
The real question is "will the hardware or software that produces the sound be able to keep up?"
After all, it's got to receive and interpret the two Bank Select messages and a Program Change, followed by actually doing the change, however that's done.
Remember, in the guidelines it suggests that the average time (hardware) to implement a GM System On message is 100ms.
It would be considerably less to switch kits, I suggest, but still not zero time, and that will vary from system to system.

Any help?
JohnG
2 years ago
·
#9096
0
Votes
Undo
The real question is "will the hardware or software that produces the sound be able to keep up?"
After all, it's got to receive and interpret the two Bank Select messages and a Program Change, followed by actually doing the change, however that's done.
Remember, in the guidelines it suggests that the average time (hardware) to implement a GM System On message is 100ms.
It would be considerably less to switch kits, I suggest, but still not zero time, and that will vary from system to system.


I guess that's the million dollar question :p

After all of my testing so far using 541 different midi files (of my other functionality, not this particular percussion kit switching), I have found a handful (usually XG) with multiple percussion channels, and I do have one file with three percussion (channels 9, 10, 11). Some of them do in fact have multiple kits per channel, though I have not analyzed them to see how the kits are distributed. See the screenshot for the 3 channel one. Channel 9 has kits 24 and 25 (msb 127), channel 10 has 25 on bank msb 127 (standard drum kits) and 0 and 1 on bank msb 126 (SFX kits). Channel 11 has kit 25 (msb 127). It is also a format 0 midi file, so all of this info is in a single track, but again, I haven't dug in to its internals to see how it is laid out.
2 years ago
·
#9097
0
Votes
Undo
If you want to poke around in a few of these yourself,
https://reasonstation.nl/downloads/yamaha/licensed-midi-files/Yamaha-XG-Midi-Library/

The 3-percussion one is XGTECHNO under the XGSONG folder
2 years ago
·
#9098
0
Votes
Undo
Hello,

I downloaded the pack of files, although the initial link did not work for me, but with the help of Google I was able to sort something out.

I found the file you specifies, i.e. XGTECHNO.

When I loaded this into SynthFont, it game info rather different to your notes, and pics. Some similarities, but not the same. Bear in mind that the text descriptions for the various Patch/Instrument settings will be dependant on the information available to the software, so the info I was seeing could well be from the SF file I'm using within SynthFont, which is 'Timbres of Heaven'. This has a degree of XG compatibility, but I guess not 100%.

I then got my DOS midi machine running, and loaded the fine into that. To play through my Yamaha MU90r which is 100% XG compatible. The device uses an LCD screen to say what it is receiving/playing, as per it's own instrument settings.

This now seems to be much more like what you were describing, i.e. various drum changes, and drums on Ch 9, 10 and 11.

The most important thing as far as this thread in concerned is that this midi file is actually some sort of demo piece, and there are 4 or 5 different 'songs' one after the other, although the last piece is just a succession of short bursts. The changes to the drum kits are all (I think) during the break/gap between the different sections, i.e. any pause is not heard. Even so, the LCD screen on the MU90r was changing pretty much instantly, so the device would appear to be handling the Kit changes without any problem. The LCD screen was also showing the transition, and the current kit name, without any problem. So no indication of any reason to worry.

The fact that it may be a Type 0 midi file is not really an issue. It does not affect play, the data is still divided up according to channels. Just on one track. If you load this file into many playback systems, you will probably be asked if you want to split the data between tracks dependant on channels, and if you do that, you will also have the option to save the data in the split form.

My the way, the file sounds pretty good on the Yamaha device. Maybe TOO 'techno' for my taste, but so what. I'll have to check out some of the other files in the archive. On the basis of a VERY quick look through the dir listings, there are some of the files that I already have in my collection, but only a few percent of the whole download.

Geoff
2 years ago
·
#9104
0
Votes
Undo
Bear in mind that the text descriptions for the various Patch/Instrument settings will be dependant on the information available to the software,

I am using two modified Cakewalk Instrument Definition files for my XG names (sw1000xg and 9000Prov100, the first is more complete, the second has nicer names), plus another for my GS names (Roland SC-8850), and a fourth for my GM names (GM1_GM2). I tried to use names from the most recent device file I could find.

I'm not sure where SynthFont pulls it's names from. I also have Timbres Of Heaven as one of the soundfonts in VirtualMIDISynth, and play my midis through Winamp. It doesn't show any names, only a midi mixer with numbers and sliders, but it does play XG decently. None of the midi editors I have seem to have extensive support for XG. They will display everything just using standard GM naming.

In that site I linked, I noticed the author made some mp3s of some of the tracks, and I have to say, they sound really nice coming from a real XG device. Mine plays pretty decent, but don't sound anywhere near as polished. I have the Yamaha XG player along with the S-YXG 100 softsynth installed in a Win 98 virtual machine, I'll have to give it a listen on there to see how it sounds.
2 years ago
·
#9112
0
Votes
Undo
If you want to analyse a MIDI file in some detail, one of the best programs available today to do this is one called Sekaiju from the OpenMIDIproject.
Best of all it's a FREEBIE. It can be found here: 'openmidiproject.osdn.jp/index_en.html'

This particular program, in its List View, allows you to select exactly what you want to see and not see by leaving ticked/unticking the boxes on the RHS to leave, e.g., just MSB, LSB, PC checked.
And I can confirm what Geoff says, the changes are executed between the various "songs" (I'm not keen on Techno either ;-)) not many of them with little time between them.
Having said that, I suspect that most software and hardware that can respond to Program Changes (many VST sample players can't) will be able to switch 'on the fly' providing you leave a millisecond or so between the PC and the next Note On message.

I tried the file using the Yamaha SOL2 program and the Yamaha S-YXG50 soft synth and it worked perfectly.
Most of these files will render perfectly except where they are designed to use a specific synthesiser/PLG card, e.g. DX, AN, VL.
I must dig out my old MU1000 with its three synth cards (as above) and try them again.
They are stunning quality.

JohnG.
2 years ago
·
#9127
0
Votes
Undo
Hello Jason,

Regarding your note re the text names, I've just checked my installation. In the dir containing the big SF file for Timbres there are two support files.

timbres.txt contains the text info, with the patch number/reference (bank and patch), this is plain text and can be edited.
Timbres_of_Heaven.mlb is substantially binary info, but also contains the patch names, and is grouped in instrument types, a bit like GS patches are structured. The info must be coming from one of these.

Geoff
2 years ago
·
#9136
0
Votes
Undo
Once I add in the functionality (on a trial basis), I'll try messing with a file, and if one of you fine folks could test it out on hardware with its rapid kit switching and tell me the results, that would be swell :) I'll post it (or maybe a few for completeness) on here when they are at that point. I'l probably do at least one file in each format (GM, XG, GS).

I still have to work on the actual insertion code. Adjusting the track length and timing will be tricky. The first tests will essentially be brute force kit/bank switch insertion (ie, where is the note? jam in a change, add to track length). If it's somewhat successful, I will optimize it.
2 years ago
·
#9137
0
Votes
Undo
Oooooh, I just thought of something...

On instrument channels it will be easier because a program change always happens for a new instrument, so I just do the bank select, then the program change.

If a bank select is sent on a percussion channel, does it ALSO require a program change to have the percussion play from the new bank/kit? Or will it play them from the new bank without specifically sending a program change? I'm thinking it might need it, in which case that's going to get really bloated quickly.
2 years ago
·
#9138
0
Votes
Undo
I'll be quite happy to play any files you upload, and report. XG or GM (and GS ?). No problem.

Regarding th setting process, I note from my Yamaha manual for the MU90r than the different drum kits require a MSB and a Prog Change number. If the last Bank Select ## was correct for the new Bank, then I believe that just the Prog Change will do the job, i.e. things stay in the currently selected Bank. But that should be checked?

With regard to the timing question, you should note something not mentioned before. Certainly in the case of the MU90r, although each bank contains a full set of instruments, many of them will be the same as in other kits. Some kits contain merely a handful of 'different' instruments. I don't know how the change is implemented in RAM within the MU, but it may well need to do anything with ONLY the note numbers that need a change, and may not have to do anything with the others. I don't think that any kit requires EVERY item to be changed.

Geoff
2 years ago
·
#9140
0
Votes
Undo
Oooooh, I just thought of something...

On instrument channels it will be easier because a program change always happens for a new instrument, so I just do the bank select, then the program change.

If a bank select is sent on a percussion channel, does it ALSO require a program change to have the percussion play from the new bank/kit? Or will it play them from the new bank without specifically sending a program change? I'm thinking it might need it, in which case that's going to get really bloated quickly.


As far as I'm aware no change will happen without the Program Change command, it's that instruction that makes the hardware/software change instrument or drum kit.

JohnG.
2 years ago
·
#9147
0
Votes
Undo
MU, but it may well need to do anything with ONLY the note numbers that need a change, and may not have to do anything with the others. I don't think that any kit requires EVERY item to be changed

Unfortunately, to make my program flexible, users will be able to do it if they want :p In theory anyway. We'll see how it goes when I get there. Since I am not actually dealing with the hardware, and I only have as much bank information as I have knowledge of, there can/will be instances (perhaps custom drum kits or whatnot, or simply something I was not aware of) where a user will have something perfectly valid that does not flag properly in my program, yet they will still be able to make bank adjustments as wanted.

So I will try to make some "worst case scenario" files for testing, to see how much chaos I can cause ;)
2 years ago
·
#9149
0
Votes
Undo
I think I'm going to have to ponder this for a while and see if I should actually do it.

Witness this screenshot of the byte locations of all the percussion/program changes in one file. Each number shown is an occurrence of that instrument, either via a program change (instrument) or note on/off (percussion).

Regular channels are fine, a bank change could happen easily before the first note.

Percussion, because each note is a different instrument, *cough* ... The amount of bank selects even to change a single one to a different kit becomes astronomical... If each one was in its own section of the file, it wouldn't be so bad, but as you can see, they are definitely interspersed.
2 years ago
·
#9150
0
Votes
Undo
* Not only would I need to change the bank for each occurrence of the percussion instrument, but I would then need to change the bank back to the original for the next percussion instrument that has not been set to the new bank.
2 years ago
·
#9151
0
Votes
Undo
Hey, this is getting way OTT.

You said at the beginning that this was a way to EASILY change the instrument in a midi file. If you're trying to include what you seem to be aiming at, this is in effect the same as changing any instrument on any track - in effect - for every note played.

Is this really necessary?

As far as the Drum Kits are concerned, most of the kits are actually the same 'instruments' in most positions. Many of the instruments are in every kit.

The important consideration would be that to make any use of this facility, the user would need to have full knowledge of every kit, and which instrument was in each kit, and calculate for each instrument at each moment of playing which actual kit that contained that instrument would be the most suitable one to activate. If you want to play instrument X, and that instrument is in kit Y, then you must activate kit Y. If you need to play instrument X and that instrument is in, say, 8 different kits, then you should determine which of those 8 kits would be 'best' to use, maybe dependant on other instruments to be played later.

So the stated aim of your prog, to allow instrument changes to be done EASILY, goes out of the window?

I would suggest that it would be quite enough to allow the specific kit setting to be changed to another kit, as you seem to be thinking of regarding normal instruments. I.E you change one Bank Select + PC to a different BS + PC.

Geoff
2 years ago
·
#9156
0
Votes
Undo
When I say "easily", I mean for the user, not necessarily the poor programmer ;) But I think I am probably going to limit it to changing whichever kit changes are already in the file (ie, there's a kit change at the beginning and one halfway through, allow those to be changed, and modify ALL corresponding percussion rather than the individuals) or perhaps allowing the insertion of one at a specified point in the file. My original idea of treating them like a standard instrument channel I think is too much. Though I'm still curious how hardware would respond. I'll probably update my instrument lists for drum kits to highlight all the percussion currently in use so you can tell at a glance which kit will work best.
2 years ago
·
#9159
0
Votes
Undo
Hello,

When I referred to 'easily', I was thinking about the user.

Some of what you say just now does not make sense. Please consider that the drum kit is in effect a single instrument, except that each different note in the instrument in fact plays a different sound. As soon as you change the kit, then you automatically change all the indiv sounds in just the same way that you would change all the sounds if you changed a Piano instrument to a Trumpet instrument.. So you don't need to modify anything else. And you ARE treating it exactly like a normal instrument change.

There is however the question as to this sounding right. Most of the diffent kits will have similar instruments in similar parts of the note number range, so that changing the kit will usually still be reasonable, but this will not be guaranteed. Probably, in some cases, a changed kit will result in a percussion track that sounds plain wrong! You can prob tell this ONLY when listening to the result. You should study some drum kits, and note how different they are (and also how similar they are, and how interchangeable they are). I'd also suspect that the vast majority of the sounds ACTUALLY USED from eack kit is merely a small proportion of the whole kit.

Geoff.
2 years ago
·
#9162
0
Votes
Undo
Some of what you say just now does not make sense. Please consider that the drum kit is in effect a single instrument, except that each different note in the instrument in fact plays a different sound.

Yes, I think I have been staring at the code for too long :p

I use the same code in my program to do several different things. Much of it processes both normal instruments (only with program changes) and percussion (with note-on/note-off). I keep "thinking" drum kits are separate banks, like instrument banks, though I know you change them with a regular program change and not a bank select. (Are they like banks? What actually happens in hardware when you do a kit change? Does it swap out all of the drum sounds, or does it just point to another location to play the sounds from?)

To clarify, my intent is to treat each percussion note as a stand-alone instrument during file modification. My program can already do this, no problem, as long as no kit changes are involved.

For example, a file has a drum track using
GM Kit 0 Standard Set
37 Bass Drum 1
39 Acoustic Snare

I would let the user choose any other drum kit for either the drum or cymbal (or both), and it would (theoretically) hop between the kits (via program changes) as the track plays. They could also change the drum or cymbal in to any other instrument from the new kit as desired.

So after modification,
GM Kit 0 Standard Set
37 Bass Drum 1

GM Kit 48 Orchestra Set
51 Timpani D (used to be Kit 0 39 Acoustic Snare)

The file would then need to rapidly alternate between Kit 0 and Kit 48 every time a drum is followed by a timpani and vice versa. This was the original question for this particular post, whether this was possible and whether it was feasible. It would require inserting lots of program changes, Thankfully, now that my brain has been on other things for a few days, I realize it does not also need a bunch of bank selects inserted ;) Which dramatically increases the feasibility of doing it. I think.

But practically speaking from a programming standpoint, it would be easier for me to only allow changes that move all percussion currently on a particular kit to a new kit, rather than being able to piece it up all willy nilly. So if the user chose to change GM Kit 0 to GM Kit 48, all percussion on the track from GM Kit 0 would also go to Kit 48.

If it helps to visualize, here's a screenshot of drum kits in a GS file. the currently selected kit is the blue one in the middle. Kits can be changed by pressing left or right, instruments by pressing up or down.
drum_kits.png
2 years ago
·
#9163
0
Votes
Undo
Also, (can't edit previous reply) when I say treat each percussion as its own instrument, I mean each percussion item as a whole, which is what I do. So in my example from above, each "note on" for "37 Bass Drum 1" belongs to a single "Bass Drum 1" instrument, just as each "note on" for "39 Acoustic Snare" belongs to a single "Acoustic Snare" instrument. I would not want to treat each "note on" as it's own, just in case I accidentally gave that impression. THAT would just be downright silly :p

Thusly, as far as the user is concerned, it is still easy. Select new kit, select new instrument, done. :)
2 years ago
·
#9164
0
Votes
Undo
Please note that if you specifically want to change percussion item x from instrument X to instrument Y then there are two options.

If both instruments are in the same Kit, then you do NOT even need to change the kit, you simply need to change the note number. You may HAVE to do that anyway, if that specific sound is always a different note number.

Probably, if you MUST change the kit because the new sound is not present in the current kit, then you may still need to change the note number. In which case you need the Bank Select, then the Program Change, then change the note number. Of course, if you have to change the note number like this, then you need to change ALL the following note numbers for the same instrument change.

This might be practical if you use your own playback software. You can introduce a table into the prog, so that the note ## in the playback midi file is checked in the table and if the instrument has been changes then the note number is corrected from the tale and the changed note number is send for playing. I don't know if any existing playback software will do this?

.Geoff
  • Page :
  • 1
  • 2
There are no replies made for this post yet.