Difference between revisions of "Enterprise MIDI English"

From Enterprise Wiki
Jump to: navigation, search
(Special settings for the MIDI files)
(Converting MIDI files to midiplay format)
 
(31 intermediate revisions by 3 users not shown)
Line 6: Line 6:
 
* Installing a midi port e.g. [https://www.tobias-erichsen.de/software/loopmidi.html loopMIDI]. In Linux the Midi Through port can be used or editor programs (e.g. Qtractor) also can create a port that can be directly connected to the emulator. A hardware midi keyboard can also be used, in this case loopMIDI is not needed.
 
* Installing a midi port e.g. [https://www.tobias-erichsen.de/software/loopmidi.html loopMIDI]. In Linux the Midi Through port can be used or editor programs (e.g. Qtractor) also can create a port that can be directly connected to the emulator. A hardware midi keyboard can also be used, in this case loopMIDI is not needed.
  
* An EP128Emu version that supports midi input. (The latest emulator can be downloaded from sourceforge, this should be updated with [https://enterpriseforever.com/ep128emu/ep128emu/msg65290/#msg65290 this] newer beta version. So it only needs unpacking and you should overwrite the existing files of the emulator.)
+
* An EP128Emu version that supports midi input, the latest emulator can be downloaded from [https://github.com/istvan-v/ep128emu/releases GitHub].
  
* An EP application called midiplay ([https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18796 current version], older releases: [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18726 1], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18716 2], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18703 3], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18675 4])
+
* An EP application called midiplay ([https://github.com/istvan-v/midiplay/releases current version], older releases: [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=19089 1], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18796 2], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18726 3], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18703 4], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18675 5])
  
 
If using Windows is the case, you need to configure the midi input (loopMIDI port (I MMSystem)) in the Options -> Sound -> Configure menu item. After that, start a midi player, editor, or virtual keyboard on the PC where output the loopMIDI OUT is set. Start the emulator, load the application called Midiplay on it. After that, the midi player's will sound on the emulated EP, using DAVE's capabilities.
 
If using Windows is the case, you need to configure the midi input (loopMIDI port (I MMSystem)) in the Options -> Sound -> Configure menu item. After that, start a midi player, editor, or virtual keyboard on the PC where output the loopMIDI OUT is set. Start the emulator, load the application called Midiplay on it. After that, the midi player's will sound on the emulated EP, using DAVE's capabilities.
Line 18: Line 18:
 
=== How to use Midiplay in the emulator? ===
 
=== How to use Midiplay in the emulator? ===
 
With this application you can play the midi file with the emulated EP as the instrument. If you are using a midi editor (eg Cakewalk, Sonar, etc.), you can also hear the notes through the emulator.
 
With this application you can play the midi file with the emulated EP as the instrument. If you are using a midi editor (eg Cakewalk, Sonar, etc.), you can also hear the notes through the emulator.
It is possible to convert an edited midi file into a loadable and playable EP file (midiconv, see below). Midiplay will automatically check if the default folder contains a converted file called mididata.bin (the maximum size is 1040 bytes of header + 8192 bytes of envelope + 28671 bytes of MIDI data) and, if it is found, the song will be played indefinitely in a loop. If there is no such file, the app will wait for notes received via loopMIDI. While the program is running, the screen will stay completely dark, as no special display is required. It is desirable to run the app on a turbocharged (eg 10 MHz) configuration, but it also works at 4 MHz.
+
It is possible to convert an edited midi file into a loadable and playable EP file (midiconv, see below). Midiplay will automatically check if the default folder contains a converted file called mididata.bin (the maximum size is 1040 bytes of header + 8192 bytes of envelope + 31743 bytes of MIDI data) and, if it is found, the song will be played indefinitely in a loop. If there is no such file, the app will wait for notes received via loopMIDI. While the program is running, the screen will stay completely dark, but newer releases also include mididisp.com with support for simple visualization. It is desirable to run the app on a turbocharged (eg 10 MHz) configuration, but it also works at 4 MHz.
  
 
Once started the app, you can use these buttons:
 
Once started the app, you can use these buttons:
  
F1: Restarts the program, rewrites envelope.txt and (if available) mididata.bin .
+
F1: Restarts the program, rereads envelope.txt and (if available) mididata.bin .
  
 
F4: Switches off all sounds, useful for "stuck" sounds. The MIDI controller 123 can also be used for similar purposes.
 
F4: Switches off all sounds, useful for "stuck" sounds. The MIDI controller 123 can also be used for similar purposes.
  
F6: Full MIDI reset, with the exception of all sounds, the controls, bend and instruments are reset, and the playback position is also returned to the start of the file. The controls and bending can also be reset with the 121 controller.
+
F6: Full MIDI reset, all sounds, controllers, bend and instruments are reset, and the playback position is also returned to the start of the file. The controls and bending can also be reset with the 121 controller.
  
 
F8: Exit.
 
F8: Exit.
  
  
Which MIDI channel (1-16) correspond to each Dave channel? Midi channels are managed by the player as "logical" channels. So each of the eleven(sixteen?) stores their entire status separately:
+
Which MIDI channel (1-16) correspond to each Dave channel? Midi channels are managed by the player as "logical" channels. So each of the sixteen stores their entire status separately:
  
 
* from the 128 keys, which one is pressed and, if so, the assigned DAVE channel.
 
* from the 128 keys, which one is pressed and, if so, the assigned DAVE channel.
Line 41: Line 41:
  
 
* in case of an incoming note on the percussion Midi channel (10), it will be played unconditionally on the DAVE channel 3, immediately interrupting the previous sound.  
 
* in case of an incoming note on the percussion Midi channel (10), it will be played unconditionally on the DAVE channel 3, immediately interrupting the previous sound.  
* otherwise, from the 0-2 Dave channels, one is better choice than the other two when they are through the envelope process (off> release> attack / decay> sustain), then
+
* otherwise, from the 0-2 Dave channels, one is better choice than the other two when they are through the envelope process (off> release> attack / decay> sustain), then
 
* if you have not been able to make a decision and you need to interrupt the active sound because all 3 music channels are busy, the older (or previously released) sound will be replaced
 
* if you have not been able to make a decision and you need to interrupt the active sound because all 3 music channels are busy, the older (or previously released) sound will be replaced
 
* if they are equal then a fixed order will be followed:
 
* if they are equal then a fixed order will be followed:
Line 55: Line 55:
 
  Left = ENV_L * ((VELOCITY + AFTERTOUCH + 1) / 128) * ((VOLUME + 1) / 128) * cos(PAN * (PI / 2) / 127.5) * sqrt(2)
 
  Left = ENV_L * ((VELOCITY + AFTERTOUCH + 1) / 128) * ((VOLUME + 1) / 128) * cos(PAN * (PI / 2) / 127.5) * sqrt(2)
 
  Right = ENV_R * ((VELOCITY + AFTERTOUCH + 1) / 128) * ((VOLUME + 1) / 128) * sin(PAN * (PI / 2) / 127.5) * sqrt(2)
 
  Right = ENV_R * ((VELOCITY + AFTERTOUCH + 1) / 128) * ((VOLUME + 1) / 128) * sin(PAN * (PI / 2) / 127.5) * sqrt(2)
Where ENV_L = left envelope, ENV_R = right envelope, VELOCITY = strength of the key hit, AFTERTOUCH = extra pressure strength, VOLUME = volume (control 7), PAN = stereo position (control 10). If the envelope curve can be multiplied by 1, the multiplier is limited to 1. So, adjusting the stereo position only works correctly if VELOCITY and VOLUME together result in a minimum 3 dB reduction in the volume. The volume multiplication is actually only 1/128 resolution.
+
Where ENV_L = left envelope, ENV_R = right envelope, VELOCITY = strength of the key hit, AFTERTOUCH = extra pressure strength, VOLUME = volume (control 7), PAN = stereo position (control 10). If ENV_L or ENV_R would be multiplied by greater than 1, the multiplier is limited to 1. So, adjusting the stereo position only works correctly if VELOCITY and VOLUME together result in a minimum 3 dB reduction in the volume. The volume multiplication is actually only 1/128 resolution.
The AFTERTOUCH parameter is set by the Axh and Dxh MIDI events, as the last key, the latter on the same channel at all active tones at the same time(?). For a new sound (event 9xh), always zero is the initial value.
+
The AFTERTOUCH parameter is set by the Axh and Dxh MIDI events, the former separately for each key, while the latter for all active notes on the same channel. For a new sound (event 9xh), the initial aftertouch value is always zero.
  
 
=== Special settings for the MIDI files ===
 
=== Special settings for the MIDI files ===
Line 63: Line 63:
 
For this, in the midi file, different controls can be used for different Dave specific settings. (Controllers are generally available in midi editing programs in the Controllers menu.)
 
For this, in the midi file, different controls can be used for different Dave specific settings. (Controllers are generally available in midi editing programs in the Controllers menu.)
  
71 (Harmonic Content) and 76 Controllers: STYLE Parameter / 4
+
==== Using MIDI Controllers ====
 +
 
 +
'''71 (Harmonic Content) and 76 Controllers:''' STYLE Parameter / 4
  
 
The Style parameter is the same as the one after the Basic command SOUND STYLE, only divided by 4. So, for example, if 16 (low distortion) is desired, then 16/4 = 4 must be entered. If 144 (ring modulation + low distortion)must be applied, then 144/4 = 36 should be specified.  
 
The Style parameter is the same as the one after the Basic command SOUND STYLE, only divided by 4. So, for example, if 16 (low distortion) is desired, then 16/4 = 4 must be entered. If 144 (ring modulation + low distortion)must be applied, then 144/4 = 36 should be specified.  
  
?????Four-stitch 4-bit distortion 2 adds the frequency correction, instead of the default 15, results in a 5-length pattern (higher)??????
+
When using 4 or 5 bit distortion, the frequency is automatically corrected to avoid "bad" pitch values where there is no sound or the pitch would be much higher than expected. These occur because of how polynomial counter distortion is implemented on DAVE channels 0 to 2: the counters run constantly at a clock frequency of 250 kHz, and are looping a pseudo-random pattern of 2^N-1 (15, 31 and 127 for 4, 5 and 7 bits, respectively) samples. These counters are then sampled at a frequency of 250000 / (F + 1) Hz, where F is the pitch value written into DAVE registers A0h to A5h. Therefore, if F+1 and the length of the polynomial counter pattern can be divided evenly by the same integer number, then a shorter pattern will be output, possibly no sound if the length is reduced to 1.
 +
 
 +
In the case of 4-bit distortion, if bit 1 of the controller is set (2 is added to the value), then the frequency is corrected so that the pattern length will be 5 instead of the maximum (15).
 +
 
 +
The correction works by adding an offset to the DAVE pitch, depending on the remainder of dividing the original value by 15 (4-bit) or 31 (5-bit). For 5-bit distortion, 1 is added (slightly lower frequency) if the remainder is 30. 4-bit distortion uses the following tables:
 +
Pattern length = 15:  0,  0, -1,  0, -1,  1,  0,  0, -1,  1,  0,  1,  0,  0,  1
 +
Pattern length = 5:  2,  1,  0, -1,  1,  0, -1,  1,  0, -1,  1,  0, -1, -2,  3
 +
The latter can overflow if the pitch is very low.
  
Sound Variation (70) and Control 77 (Channel Control) only affect the bits 2 to 4:
+
'''Sound Variation (70) and Control 77 (Channel Control)''' only affect the bits 2 to 4:
  
 
- 0 = dynamic reservation
 
- 0 = dynamic reservation
  
- 4 = fixes channel 0(one part only)
+
- 4 = fixed channel 0 (one note only)
  
- 8 = fixes channel 1
+
- 8 = fixed channel 1
  
- 12 = fixes channel 2
+
- 12 = fixed channel 2
  
- 16, 24 = channel 0, up to 3 simultaneous voices system (this is more the same way MIDI channel is also possible)
+
- 16, 24 = channel 0, up to 3 simultaneous voices system (the notes are alternated on the same channel at a frequency of 50 Hz)
  
 
- 20, 28 = Channel 1, up to 3 voices may alternate in the same way
 
- 20, 28 = Channel 1, up to 3 voices may alternate in the same way
Line 86: Line 95:
  
 
=== How to use ENVELOPE.TXT ===
 
=== How to use ENVELOPE.TXT ===
A midi fájlok különféle hangszerek hangját szólaltatják meg. Az envelope.txt ezekhez a hangszerekhez társít hangzást (burkológörbét), ezt felhasználva fog megszólalni a Dave képességeit használva EP-n. Csak valós idejű bemenetnél (MIDI port) és fejléc nélküli mididata.bin lejátszásánál van szükség a használatára, az újabb formátumú konvertált fájlok tartalmazzák a hangszereket is.
+
Midi files play the voices of various instruments. Envelope.txt will associate the sound (envelope curve) with these instruments, using this to use Dave's capabilities on EP. It is only necessary to use it for playback on a real-time input (MIDI port) and header-free mididata.bin, newer-format converted files also include the instruments.
  
Egy "hangszer" definíciója így néz ki:
+
The definition of an "instrument" looks like this:
  
  <nowiki>HANGSZER[D][P][:+CSATORNA,+MAGASSÁG][,HANGSZER2...] {</nowiki>
+
  INSTRUMENT [D] [P] [: + CHANNEL, + PITCH] [, INSTRUMENT2 ...] {
<nowiki> [L|R|S] IDŐTARTAM, BAL, JOBB, HAJLÍTÁS, TORZÍTÁS;</nowiki>
+
  [L | R | S] DURATION, LEFT, RIGHT, BEND, DISTORTION;
<nowiki>  ...</nowiki>
+
  ...
  <nowiki>}</nowiki>
+
  }
  
Több hangszer is használhatja ugyanazt a burkológörbét, több számot megadva vesszővel elválasztva. A hangszer száma vagy 0 és 127 közötti a normál csatornákhoz, vagy -1 és -127 közötti a dobokhoz. Ezt opcionálisan követheti 'P' karakter (lásd lent), illetve kettősponttal elválasztva megadható még két további paraméter, ilyenkor a hangszer használatakor a hangjegyről másolat készül a MIDI csatorna számának és a hangmagasságnak a módosításával. Például 1:2,12-nél az 1-es hangszer a kettővel nagyobb számú MIDI csatornán is megszólaltat egy oktávval magasabb hangot.
+
Multiple instruments can use the same envelope, multiple numbers separated by commas. The number of instruments is between 0 and 127 for normal channels, or between -1 and -127 for drums. Optionally, the number can be followed by the 'D' or 'P' characters (see below), or select two additional parameters separated by a colon. When using the latter, each note on the instrument will be duplicated with the specified offsets added to the MIDI channel and pitch (the values wrap around if they overflow). For example, with 1:2,12, Instrument 1 also plays a second note an octave higher on the MIDI channel 2 higher (or 14 lower if it would overflow) than the current one.
  
A hangszer száma utáni 'D' karakter kényszeríti a burkológörbe teljes lefutását a billentyű korai elengedésekor is, doboknál és 'R' szegmenst tartalmazó burkológörbéknél ez az alapértelmezés, így ott értelmetlen a használata, 'L' vagy 'S' esetén pedig hibát eredményez. A 'P' a hangok sztereó pozícióját változtatja a hangmagasságtól függően, dobnál nincs hatása. Alapértelmezés szerint a 48..79 tartományba eső hangok kerülnek 1..125 pozícióra, ez a 10-es vezérlővel módosítható. A 9-es hangszernél (Glockenspiel) az effektus alapértelmezés szerint bekapcsolt állapotú és a 'P' tiltja.
+
The 'D' character after the instrument number forces the full envelope curvature to be released even when the key is released early, for drums and 'R' envelope curves, this is the default, so there is no use for it, and combining 'D' with 'L' or 'S' results in an error. 'P' changes the stereo position of the sounds depending on the pitch, no effect on the drum. By default, the ranges between 48 to 79 are set to 1..125, [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18982;image this can be changed with controller 10]. With the 9 instrument (Glockenspiel), the effect is enabled by default and is turned off by 'P'.
  
Az időtartam (ami video megszakítás egységekben adható meg, 0 esetén a paraméterek változása azonnali) előtt az 'S' karakter azt jelenti, hogy az adott szegmens kezdete "sustain" pozíció, ahonnan a lejátszó csak a billentyű elengedésekor lép tovább. Ennek doboknál nincs értelme. A burkológörbe egy szakasza ismételhető is az 'L' karakter használatával, amely önmagában a burkológörbe további részét végteleníti elengedési fázis hozzáadása nélkül. Az 'R' hatása hasonló az 'S'-hez, de azzal ellentétben a burkológörbe mindig lefut a végéig, 'S'-nél viszont az azzal megadott pont elérése előtt azonnal megszakad. Az 'L' és 'R' együttes használatakor az ezek közötti szakasz ismétlődik (az L-es szegmens elejétől az R-es előtti végéig), elengedéskor pedig az ismétlődés megszűnik és a burkológörbe lefut a végéig.
+
The duration (which can be set in video interrupt units, 0 changes the parameters immediately), the character 'S' means that the beginning of the segment is a "sustain" position from which the player will only continue when the key is released. It does not make any sense for the drums. A section of the envelope can be repeated using the 'L' character, which will play in a loop infinite the rest of the envelope without adding a release phase. The effect of 'R' is similar to 'S', but in contrast, the envelope always runs to the end with 'R', but with 'S' it immediately stops if the key is released before reaching the specified point. When using 'L' and 'R' together, the interval between them is repeated (from the beginning of the L segment to the end of the segment before R), and at the time of release, the repeat disappears and the envelope runs to the end.
  
Az EXOS-tól eltérően a hangerők abszolút értékek 0 és 63 között, azt adják meg, hogy mi lesz az új hangerő a következő szegmens elején, amit lineáris interpolációval ér el. Lehetőség van azonban exponenciális burkológörbék definiálására is, ha a hangerő érték előtt '*' karakter található, akkor a megadott szám / 128-al szorzódik a hangerő minden megszakításnál. Tehát például *96 esetén 0.75 a szorzó, *128-nál nem változik a hangerő, stb. A hajlítás egy -2048 és +2047 közötti egész, 64 felel meg egy zenei félhangnak. Itt is lineáris interpoláció történik, és a megadott értéket a következő szegmens elejére éri el. Dobokat nem lehet hajlítani.
+
Unlike EXOS, the volume is an absolute between 0 and 63, it is given the new volume at the beginning of the next segment that is reached by linear interpolation. However, it is also possible to define exponential envelope curves if the volume value is '*' before the volume value, then the number / 128 is multiplied by volume at each interruption. For example * 96, 0.75 is the multiplier, * 128 does not change the volume, etc. Bending is between -2048 and +2047, 64 corresponding to a musical semitone. Linear interpolation is also done here and the specified value reaches the beginning of the next segment. Drums can not be bent.
  
A torzítás (STYLE) a többi paraméterrel ellentétben nem interpolálható, hanem az értéke azonnal módosul, erre figyelni kell ha változik a hang közben.
+
Distortion (STYLE) can not be interpolated in contrast with the other parameters, but its value is immediately changed, and it needs to be watched when it changes in sound.
  
Szóközök, Tab karakterek és új sorok tetszőlegesen használhatók, a program ezeket figyelmen kívül hagyja. '#' karakter esetén a sor további részét megjegyzésnek tekinti és szintén figyelmen kívül hagyja.
+
Spaces, Tab characters and new rows can be used arbitrarily, the program ignores them. In the case of the '#' character, the rest of the line is considered a comment and ignored.
 +
The player program automatically stores the compiled (binary) envelope data into a file called envelope.bin. The format is:
 +
* 256 bytes define the duplication of notes for each instrument, the first byte is +CHANNEL and the second is +PITCH, or both are FFh if the feature is not used by the instrument
 +
* the following 256 bytes are the same for the drums, in the same format
 +
* 256 bytes envelope start position for normal instruments: bottom, top byte alternately, or 8080h if the instrument is not defined. The start position is relative to the beginning of the envelope data and is divided by 2, and the top 4 bits have a special function, so the maximum size of the addressable envelope data is 8192 bytes. The flag bits default to 2000h, which is not changed by using 'S'.
 +
** bit 15: disables the instrument
 +
** bit 14: pitch-dependent stereo position (P)
 +
** bit 13: indicates the absence of a repeating stage (L)
 +
** bit 12: releases the full envelope curve (D or R)
 +
* 256 bytes envelope position for drums
 +
* up to 8192 bytes envelope data, every 50 Hz interrupt 4 bytes:
 +
** left volume between 0 and 63. Setting bit 6 is the beginning of a repeating phase (L), and 8 is the end that no longer repeats. The two bits are set together to hold the current sample and then indicate a release phase (only R or S). It is a special case when the left volume has bit 7 set and the right volume is FFh, this indicates the end of the envelope and turning off the sound.
 +
** right volume between 0 and 63, or 255 at the end of the envelope
 +
** bend lower 8 bits, its resolution is half a 1/64 part. Not used in drums
 +
** distortion and (for normal instruments only) the upper 4 bits of the bend are stored. In the case of a percussion instrument, it defines the full byte distortion
  
 +
=== Converting MIDI files to midiplay format ===
 +
Once we have finished editing a MIDI file, and it sounds correctly with DAVE instruments, it can be converted so it can be listened on the EP standalone. [https://github.com/istvan-v/midiplay/releases midiconv] (older version [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=19089 1], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18796 2], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18621 3]) is a command line application. On Windows, the command line interface (cmd.exe) can be accessed via the Start Menu. After entering the directory where midiconv.exe is with the CD command, it can be used as follows:
  
A lejátszó program a lefordított (bináris) burkológörbe adatot automatikusan menti egy envelope.bin nevű fájlba. Ennek a formátuma:
+
midiconv INFILE.MID OUTFILE.BIN ENVELOPE.BIN|ENVELOPE.TXT|-raw [IRQFREQ] [-optsort] [-renumber] [-quantN] [-biasN] [-render] [-1..-9]
* 256 bájt a normál hangszerek másolását definiálja, csatorna és magasság eltolás felváltva (csak az alsó 4 illetve 7 biten), FFFFh esetén ez a funkció tiltott
+
midiconv ENVELOPE.TXT ENVELOPE.BIN -env [-1..-9]
* a következő 256 bájt ugyanez a dobokhoz, azonos formátumban
 
* 256 bájt burkológörbe kezdő pozíció a normál hangszerekhez: alsó, felső bájt felváltva, a burkológörbe adat kezdetéhez képesti eltolás / 2, vagy 8080h ha a hangszer nem definiált. A felső 4 bit speciális funkciót tölt be, ezért a címezhető burkológörbe adat maximális mérete 8192 bájt. Az alapértelmezés 2000h, amit az 'S' használata nem változtat.
 
** 15. bit: tiltja a hangszert
 
** 14. bit: hangmagasságtól függő sztereó pozíció (P)
 
** 13. bit: ismétlődő szakasz (L) hiányát jelzi
 
** 12. bit: elengedéskor kényszeríti a teljes burkológörbe lefutását (R)
 
* 256 bájt burkológörbe pozíció a dobokhoz
 
* legfeljebb 8192 bájt burkológörbe adat, minden 50 Hz-es megszakítás 4 bájt:
 
** bal hangerő, 0 és 63 között. A 6. bit beállítása ismétlődő szakasz kezdetét (L) jelzi, a 8. pedig a végét ami már nem ismétlődik. A két bit együttesen beállítva az aktuális minta tartását, majd elengedési szakaszt jelez (csak R, vagy S). It is a special case when the left volume has bit 7 set and the right volume is FFh, this indicates the end of the envelope and turning off the sound.
 
** jobb hangerő 0 és 63 között, vagy 255 a burkológörbe végén
 
** hajlítás alsó 8 bit, a felbontása egy félhang 1/64-ed része. Doboknál nem használt
 
** torzítás, és (csak normál hangszereknél) a hajlítás felső 4 bitje előjelesen. Dob esetén a teljes bájt torzítást definiál
 
  
=== Converting MIDI files to midiplay format ===
+
The second form of the command converts text format instrument definitions to binary format. When converting MIDI a file, the following options can be used:
Once we are done editing a MIDI file, and it sounds good with DAVE instruments, it can be converted so that it can be listened to on the EP. [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18796 midiconv] (older version [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18705 1], [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=18621 2]) is a command line application. On Windows, the command line interface (cmd.exe) can be accessed via the Start Menu. After entering the directory where midiconv.exe is with the CD command, it can be used as follows:
 
  
midiconv INFILE.MID OUTFILE.BIN ENVELOPE.BIN|ENVELOPE.TXT|-raw [IRQFREQ]
+
* IRQFREQ (defaults to 50.0363 Hz): the assumed interrupt frequency of the playback, currently this can only be the 50 Hz video interrupt generated by the NICK chip, but other values may be useful to speed up or slow down the music. If the original tempo is 125 or 150 BPM, or other value where the duration of a quarter note is an exact integer multiple of 20 ms, it is recommended to set IRQFREQ to 50
 +
* -optsort: sorts note events that occur at the same time in a way that attempts to minimize the size of the output MIDI data, otherwise the sorting is done by channel number
 +
* -renumber: renumbers instruments starting from 0, but does not change the numbering of percussive instruments
 +
* -quantN: if N is not 0 (it can be an integer number in the range 1 to 9), then the tempo is adjusted automatically so that the duration of a quarter note becomes an exact integer multiple of N interrupts
 +
* -biasN: adjusts the rounding of MIDI event times when converted to Enterprise interrupts, N is an integer from 0 to 99 (the default is 25), 0 rounds down, 99 rounds up, and 50 rounds to the nearest integer
 +
* -N: enables compression if N is not 0, the allowed range is 0 to 9. Greater values may reduce the size of the output file, but this is not guaranteed, N above 6 will sometimes increase the file size by a small amount
 +
* -render: generates raw DAVE register data (16 bytes per frame) by emulating midiplay
  
By default, IRQFREQ is 50.0363 Hz. If the tempo of the music is 125 or 150 BPM, or other value where the duration of a quarter note is an exact integer multiple of 20 ms, it is recommended to set IRQFREQ to 50.
 
 
After running the command, the .bin file immediately appears in the same folder, and it can be played with the midiplay.com or midi_asm.com application on the Enterprise.
 
After running the command, the .bin file immediately appears in the same folder, and it can be played with the midiplay.com or midi_asm.com application on the Enterprise.
  
Line 137: Line 154:
 
** 2 bytes: uncompressed envelope data size
 
** 2 bytes: uncompressed envelope data size
 
** 2 bytes: uncompressed MIDI data size
 
** 2 bytes: uncompressed MIDI data size
** 8 bytes: reserved for future versions, currently always 00h
+
** 1 byte: reserved for future versions, currently always 00h
 +
*  1 byte: compression type, 0 means no compression, 2 is epcompress -m2, others are currently not supported by the player. Compressed files can only be played with midi_asm.com or mididisp.com, the C version of the player (midiplay.com) does not implement this feature yet. To unpack a compressed MIDI file, use [https://enterpriseforever.com/sound/midi/?action=dlattach;attach=19055 midipack], which is a modified version of epcompress
 +
** 2 bytes: compressed envelope data size, or 0 if the file is uncompressed
 +
** 4 bytes: reserved for future versions, currently always 00h
 
* envelope data (envelope.bin) in the above described format, midiconv automatically removes any unused envelopes
 
* envelope data (envelope.bin) in the above described format, midiconv automatically removes any unused envelopes
 
* MIDI data, the format is similar to standard MIDI files (SMF), but it contains only channel messages on a single track without header, and the delta time between events has a fixed resolution of 1/IRQFREQ seconds. For example, the following sequence of bytes plays the 440 Hz "A" note on the first MIDI channel for one second, using instrument 11:
 
* MIDI data, the format is similar to standard MIDI files (SMF), but it contains only channel messages on a single track without header, and the delta time between events has a fixed resolution of 1/IRQFREQ seconds. For example, the following sequence of bytes plays the 440 Hz "A" note on the first MIDI channel for one second, using instrument 11:
Line 144: Line 164:
 
When using the -raw parameter, the program converts to a simple headerless format that includes only the raw MIDI data. In this case, it is not necessary to specify a path to an envelope file on the command line.
 
When using the -raw parameter, the program converts to a simple headerless format that includes only the raw MIDI data. In this case, it is not necessary to specify a path to an envelope file on the command line.
  
=== Egyéb ===
+
=== Other ===
[http://oktopus.hu/a_general_midi_hangszerhangjai A midi hangszerek neve és sorszáma]
+
[http://oktopus.hu/a_general_midi_hangszerhangjai Name and program number of the midi instruments]
 +
 
 +
[https://www.midi.org/specifications/item/gm-level-1-sound-set Name and program number of the midi drums]

Latest revision as of 15:44, 12 April 2019

Introduction

A *.mid file doesn't contain any wav sample sound but only the "notes" themselves. The notes can be associated to musical instrument sounds. These instrument sounds are built into the operating system or synthesizer. Midi can sound even 16 layers (channels) at the same time and within one channel even more voices, chords. A special midi channel is the 10th where drums can sound. Our aim is to sound midi files through the EP Dave sound chip. As Dave can handle 3+1 channels altogether most midi files from the net need conversion to get suitable sounding.

Midi hardware also exists for the Enterprise but there are not many pieces. Now a PC midi player/editor application can be connected to the EP128Emu to get the EP sounding midi. To do this you need:

  • Installing a midi port e.g. loopMIDI. In Linux the Midi Through port can be used or editor programs (e.g. Qtractor) also can create a port that can be directly connected to the emulator. A hardware midi keyboard can also be used, in this case loopMIDI is not needed.
  • An EP128Emu version that supports midi input, the latest emulator can be downloaded from GitHub.

If using Windows is the case, you need to configure the midi input (loopMIDI port (I MMSystem)) in the Options -> Sound -> Configure menu item. After that, start a midi player, editor, or virtual keyboard on the PC where output the loopMIDI OUT is set. Start the emulator, load the application called Midiplay on it. After that, the midi player's will sound on the emulated EP, using DAVE's capabilities.

To minimize audio delay and timing errors, you should reduce the default latency setting (70 ms) and select an output device using a low audio API (ALSA or WASAPI), especially when using a MIDI keyboard. Also, it is advisable to avoid OpenGL video emulator modes requiring high CPUs or waiting (eg "resample to monitor refresh rate").

The EP application, Midiplay, includes several files, for example, envelope.txt, see below.

How to use Midiplay in the emulator?

With this application you can play the midi file with the emulated EP as the instrument. If you are using a midi editor (eg Cakewalk, Sonar, etc.), you can also hear the notes through the emulator. It is possible to convert an edited midi file into a loadable and playable EP file (midiconv, see below). Midiplay will automatically check if the default folder contains a converted file called mididata.bin (the maximum size is 1040 bytes of header + 8192 bytes of envelope + 31743 bytes of MIDI data) and, if it is found, the song will be played indefinitely in a loop. If there is no such file, the app will wait for notes received via loopMIDI. While the program is running, the screen will stay completely dark, but newer releases also include mididisp.com with support for simple visualization. It is desirable to run the app on a turbocharged (eg 10 MHz) configuration, but it also works at 4 MHz.

Once started the app, you can use these buttons:

F1: Restarts the program, rereads envelope.txt and (if available) mididata.bin .

F4: Switches off all sounds, useful for "stuck" sounds. The MIDI controller 123 can also be used for similar purposes.

F6: Full MIDI reset, all sounds, controllers, bend and instruments are reset, and the playback position is also returned to the start of the file. The controls and bending can also be reset with the 121 controller.

F8: Exit.


Which MIDI channel (1-16) correspond to each Dave channel? Midi channels are managed by the player as "logical" channels. So each of the sixteen stores their entire status separately:

  • from the 128 keys, which one is pressed and, if so, the assigned DAVE channel.
  • the program (instrument).
  • 4 controllers (7, 10, 76, 77)
  • bend (only the top 8 bits are taken into account, the range is fixed at +/- 2 semitones)

This information is independent of the DAVE channels in which the MIDI sounds are played. This is determined by the following algorithm:

  • in case of an incoming note on the percussion Midi channel (10), it will be played unconditionally on the DAVE channel 3, immediately interrupting the previous sound.
  • otherwise, from the 0-2 Dave channels, one is better choice than the other two when they are through the envelope process (off> release> attack / decay> sustain), then
  • if you have not been able to make a decision and you need to interrupt the active sound because all 3 music channels are busy, the older (or previously released) sound will be replaced
  • if they are equal then a fixed order will be followed:
    • MIDI channel 1: 0 > 2 > 1
    • MIDI channel 2: 2 > 0 > 1
    • MIDI channel 3: 0 > 2 > 1
    • MIDI channel 4: 2 > 0 > 1
    • ...etc.

Therefore, Dave channel 1 will be in use only when 3 music sounds are active at the same time. Exactly the other two are certainly 0 and 2. Any of the logical MIDI channels can have any number of voices, but always have a maximum of 3 + 1 percussion.

The volume of the left and right channels can be approximated in the following way:

Left = ENV_L * ((VELOCITY + AFTERTOUCH + 1) / 128) * ((VOLUME + 1) / 128) * cos(PAN * (PI / 2) / 127.5) * sqrt(2)
Right = ENV_R * ((VELOCITY + AFTERTOUCH + 1) / 128) * ((VOLUME + 1) / 128) * sin(PAN * (PI / 2) / 127.5) * sqrt(2)

Where ENV_L = left envelope, ENV_R = right envelope, VELOCITY = strength of the key hit, AFTERTOUCH = extra pressure strength, VOLUME = volume (control 7), PAN = stereo position (control 10). If ENV_L or ENV_R would be multiplied by greater than 1, the multiplier is limited to 1. So, adjusting the stereo position only works correctly if VELOCITY and VOLUME together result in a minimum 3 dB reduction in the volume. The volume multiplication is actually only 1/128 resolution. The AFTERTOUCH parameter is set by the Axh and Dxh MIDI events, the former separately for each key, while the latter for all active notes on the same channel. For a new sound (event 9xh), the initial aftertouch value is always zero.

Special settings for the MIDI files

The Midiplay player therefore pairs the individual midi channels with a certain logic to the Dave channels. However, we can also specify that a given MIDI channel must match a given Dave channel. In addition to the dynamic reservation, you can also set a fixed channel reservation. In fact, in most cases, it is necessary to use Dave's capabilities and convert the midi file downloaded from the net to a meaningful sound on EP.

For this, in the midi file, different controls can be used for different Dave specific settings. (Controllers are generally available in midi editing programs in the Controllers menu.)

Using MIDI Controllers

71 (Harmonic Content) and 76 Controllers: STYLE Parameter / 4

The Style parameter is the same as the one after the Basic command SOUND STYLE, only divided by 4. So, for example, if 16 (low distortion) is desired, then 16/4 = 4 must be entered. If 144 (ring modulation + low distortion)must be applied, then 144/4 = 36 should be specified.

When using 4 or 5 bit distortion, the frequency is automatically corrected to avoid "bad" pitch values where there is no sound or the pitch would be much higher than expected. These occur because of how polynomial counter distortion is implemented on DAVE channels 0 to 2: the counters run constantly at a clock frequency of 250 kHz, and are looping a pseudo-random pattern of 2^N-1 (15, 31 and 127 for 4, 5 and 7 bits, respectively) samples. These counters are then sampled at a frequency of 250000 / (F + 1) Hz, where F is the pitch value written into DAVE registers A0h to A5h. Therefore, if F+1 and the length of the polynomial counter pattern can be divided evenly by the same integer number, then a shorter pattern will be output, possibly no sound if the length is reduced to 1.

In the case of 4-bit distortion, if bit 1 of the controller is set (2 is added to the value), then the frequency is corrected so that the pattern length will be 5 instead of the maximum (15).

The correction works by adding an offset to the DAVE pitch, depending on the remainder of dividing the original value by 15 (4-bit) or 31 (5-bit). For 5-bit distortion, 1 is added (slightly lower frequency) if the remainder is 30. 4-bit distortion uses the following tables:

Pattern length = 15:  0,  0, -1,  0, -1,  1,  0,  0, -1,  1,  0,  1,  0,  0,  1
Pattern length = 5:   2,  1,  0, -1,  1,  0, -1,  1,  0, -1,  1,  0, -1, -2,  3

The latter can overflow if the pitch is very low.

Sound Variation (70) and Control 77 (Channel Control) only affect the bits 2 to 4:

- 0 = dynamic reservation

- 4 = fixed channel 0 (one note only)

- 8 = fixed channel 1

- 12 = fixed channel 2

- 16, 24 = channel 0, up to 3 simultaneous voices system (the notes are alternated on the same channel at a frequency of 50 Hz)

- 20, 28 = Channel 1, up to 3 voices may alternate in the same way

Fixed assignment of DAVE channels is not exclusive, the dynamic MIDI channels can continue in use.

How to use ENVELOPE.TXT

Midi files play the voices of various instruments. Envelope.txt will associate the sound (envelope curve) with these instruments, using this to use Dave's capabilities on EP. It is only necessary to use it for playback on a real-time input (MIDI port) and header-free mididata.bin, newer-format converted files also include the instruments.

The definition of an "instrument" looks like this:

INSTRUMENT [D] [P] [: + CHANNEL, + PITCH] [, INSTRUMENT2 ...] {
  [L | R | S] DURATION, LEFT, RIGHT, BEND, DISTORTION;
  ...
}

Multiple instruments can use the same envelope, multiple numbers separated by commas. The number of instruments is between 0 and 127 for normal channels, or between -1 and -127 for drums. Optionally, the number can be followed by the 'D' or 'P' characters (see below), or select two additional parameters separated by a colon. When using the latter, each note on the instrument will be duplicated with the specified offsets added to the MIDI channel and pitch (the values wrap around if they overflow). For example, with 1:2,12, Instrument 1 also plays a second note an octave higher on the MIDI channel 2 higher (or 14 lower if it would overflow) than the current one.

The 'D' character after the instrument number forces the full envelope curvature to be released even when the key is released early, for drums and 'R' envelope curves, this is the default, so there is no use for it, and combining 'D' with 'L' or 'S' results in an error. 'P' changes the stereo position of the sounds depending on the pitch, no effect on the drum. By default, the ranges between 48 to 79 are set to 1..125, this can be changed with controller 10. With the 9 instrument (Glockenspiel), the effect is enabled by default and is turned off by 'P'.

The duration (which can be set in video interrupt units, 0 changes the parameters immediately), the character 'S' means that the beginning of the segment is a "sustain" position from which the player will only continue when the key is released. It does not make any sense for the drums. A section of the envelope can be repeated using the 'L' character, which will play in a loop infinite the rest of the envelope without adding a release phase. The effect of 'R' is similar to 'S', but in contrast, the envelope always runs to the end with 'R', but with 'S' it immediately stops if the key is released before reaching the specified point. When using 'L' and 'R' together, the interval between them is repeated (from the beginning of the L segment to the end of the segment before R), and at the time of release, the repeat disappears and the envelope runs to the end.

Unlike EXOS, the volume is an absolute between 0 and 63, it is given the new volume at the beginning of the next segment that is reached by linear interpolation. However, it is also possible to define exponential envelope curves if the volume value is '*' before the volume value, then the number / 128 is multiplied by volume at each interruption. For example * 96, 0.75 is the multiplier, * 128 does not change the volume, etc. Bending is between -2048 and +2047, 64 corresponding to a musical semitone. Linear interpolation is also done here and the specified value reaches the beginning of the next segment. Drums can not be bent.

Distortion (STYLE) can not be interpolated in contrast with the other parameters, but its value is immediately changed, and it needs to be watched when it changes in sound.

Spaces, Tab characters and new rows can be used arbitrarily, the program ignores them. In the case of the '#' character, the rest of the line is considered a comment and ignored. The player program automatically stores the compiled (binary) envelope data into a file called envelope.bin. The format is:

  • 256 bytes define the duplication of notes for each instrument, the first byte is +CHANNEL and the second is +PITCH, or both are FFh if the feature is not used by the instrument
  • the following 256 bytes are the same for the drums, in the same format
  • 256 bytes envelope start position for normal instruments: bottom, top byte alternately, or 8080h if the instrument is not defined. The start position is relative to the beginning of the envelope data and is divided by 2, and the top 4 bits have a special function, so the maximum size of the addressable envelope data is 8192 bytes. The flag bits default to 2000h, which is not changed by using 'S'.
    • bit 15: disables the instrument
    • bit 14: pitch-dependent stereo position (P)
    • bit 13: indicates the absence of a repeating stage (L)
    • bit 12: releases the full envelope curve (D or R)
  • 256 bytes envelope position for drums
  • up to 8192 bytes envelope data, every 50 Hz interrupt 4 bytes:
    • left volume between 0 and 63. Setting bit 6 is the beginning of a repeating phase (L), and 8 is the end that no longer repeats. The two bits are set together to hold the current sample and then indicate a release phase (only R or S). It is a special case when the left volume has bit 7 set and the right volume is FFh, this indicates the end of the envelope and turning off the sound.
    • right volume between 0 and 63, or 255 at the end of the envelope
    • bend lower 8 bits, its resolution is half a 1/64 part. Not used in drums
    • distortion and (for normal instruments only) the upper 4 bits of the bend are stored. In the case of a percussion instrument, it defines the full byte distortion

Converting MIDI files to midiplay format

Once we have finished editing a MIDI file, and it sounds correctly with DAVE instruments, it can be converted so it can be listened on the EP standalone. midiconv (older version 1, 2, 3) is a command line application. On Windows, the command line interface (cmd.exe) can be accessed via the Start Menu. After entering the directory where midiconv.exe is with the CD command, it can be used as follows:

midiconv INFILE.MID OUTFILE.BIN ENVELOPE.BIN|ENVELOPE.TXT|-raw [IRQFREQ] [-optsort] [-renumber] [-quantN] [-biasN] [-render] [-1..-9]
midiconv ENVELOPE.TXT ENVELOPE.BIN -env [-1..-9]

The second form of the command converts text format instrument definitions to binary format. When converting MIDI a file, the following options can be used:

  • IRQFREQ (defaults to 50.0363 Hz): the assumed interrupt frequency of the playback, currently this can only be the 50 Hz video interrupt generated by the NICK chip, but other values may be useful to speed up or slow down the music. If the original tempo is 125 or 150 BPM, or other value where the duration of a quarter note is an exact integer multiple of 20 ms, it is recommended to set IRQFREQ to 50
  • -optsort: sorts note events that occur at the same time in a way that attempts to minimize the size of the output MIDI data, otherwise the sorting is done by channel number
  • -renumber: renumbers instruments starting from 0, but does not change the numbering of percussive instruments
  • -quantN: if N is not 0 (it can be an integer number in the range 1 to 9), then the tempo is adjusted automatically so that the duration of a quarter note becomes an exact integer multiple of N interrupts
  • -biasN: adjusts the rounding of MIDI event times when converted to Enterprise interrupts, N is an integer from 0 to 99 (the default is 25), 0 rounds down, 99 rounds up, and 50 rounds to the nearest integer
  • -N: enables compression if N is not 0, the allowed range is 0 to 9. Greater values may reduce the size of the output file, but this is not guaranteed, N above 6 will sometimes increase the file size by a small amount
  • -render: generates raw DAVE register data (16 bytes per frame) by emulating midiplay

After running the command, the .bin file immediately appears in the same folder, and it can be played with the midiplay.com or midi_asm.com application on the Enterprise.

The format of the converted files:

  • 16 bytes EXOS header:
    • 00h, 6Dh
    • 2 bytes: file size without the header (LSB first), in the case of future compressed formats, this would be the total size of the compressed data
    • 2 bytes: uncompressed envelope data size
    • 2 bytes: uncompressed MIDI data size
    • 1 byte: reserved for future versions, currently always 00h
  • 1 byte: compression type, 0 means no compression, 2 is epcompress -m2, others are currently not supported by the player. Compressed files can only be played with midi_asm.com or mididisp.com, the C version of the player (midiplay.com) does not implement this feature yet. To unpack a compressed MIDI file, use midipack, which is a modified version of epcompress
    • 2 bytes: compressed envelope data size, or 0 if the file is uncompressed
    • 4 bytes: reserved for future versions, currently always 00h
  • envelope data (envelope.bin) in the above described format, midiconv automatically removes any unused envelopes
  • MIDI data, the format is similar to standard MIDI files (SMF), but it contains only channel messages on a single track without header, and the delta time between events has a fixed resolution of 1/IRQFREQ seconds. For example, the following sequence of bytes plays the 440 Hz "A" note on the first MIDI channel for one second, using instrument 11:
    • 00 C0 0B 00 90 45 7F 32 45 00

When using the -raw parameter, the program converts to a simple headerless format that includes only the raw MIDI data. In this case, it is not necessary to specify a path to an envelope file on the command line.

Other

Name and program number of the midi instruments

Name and program number of the midi drums