SGI Audio Tools: Difference between revisions

Add instrument and bank information
(Add envelope, keymap, and sound properties.)
(Add instrument and bank information)
Line 164:
 
==== instrument ====
An <code>instrument</code> models a single MIDI instrument. It consists of one or more <code>sound</code>s.
 
An example <code>instrument</code> might look like:
instrument AnExampleInstrument
{
volume = 127;
pan = 64;
sound = AnExampleSound;
}
Note how <code>sound</code> property matches the name of an existing sound above.
 
An <code>instrument</code> can specify multiple <code>sound</code>. For example, <code>GenMidiBank.inst</code> in the N64 SDK uses four sounds for a MIDI Cello:
instrument Cello
{
volume = 127;
pan = 64;
 
 
vibratoType = 128; /* 128, 129, 130, 131 */
vibratoRate = 222; /* 0 to 255 */
vibratoDepth = 6; /* 0 to 255 */
vibratoDelay = 1; /* 1 to 255 */
 
sound = Cello00;
sound = Cello01;
sound = Cello02;
sound = Cello03;
}
Each of the corresponding <code>sound</code>s have different <code>keymap</code>s and samples that cover different ranges of notes. This can produce nicer-quality audio as the pitch of a sample doesn't need to be distorted as much. The tradeoff being more audio memory required for your <code>instrument</code>, especially at higher sampling frequencies such as 44100Hz.
 
For more information, review the N64 SDK Documentation at [http://n64devkit.square7.ch/pro-man/pro18/18-01.htm#02-02 18.1.2.2].
 
==== bank ====
The <code>bank</code> section is a collection of <code>instrument</code> and the final piece of the puzzle for our file. Each [http://fmslogo.sourceforge.net/manual/midi-instrument.html MIDI instrument number] gets assigned a particular <code>instrument</code>.
 
An example <code>bank</code> might look like:
bank SongBank
{
sampleRate = 32000;
percussionDefault = Percussion_Kit;
 
instrument [0] = AnExampleSound;
instrument [65] = AnExampleAltoSax;
instrument [107] = AnExampleKoto;
}
Here we associate various <code>instrument</code>s with different MIDI instrument numbers. <code>0</code> represents MIDI notes that are played with an Acoustic Grand Piano, and we've told the audio library that we should use <code>AnExampleSound</code> as the voice of Acoustic Grand Piano. MIDI notes that use instrument <code>65</code> get associated with an instrument called <code> AnExampleAltoSax</code>.
 
You'll want the value for <code>sampleRate</code> to match the frequency your sample files are tuned to. This is the reason we converted all of our samples to the same rate with SoX above.
 
<code>percussionDefault</code> is explained in the following section.
 
Note that you aren't required to have an <code>instrument</code> associated with every MIDI instrument number. If your song, for example, is only a solo piano piece then you'd only need to worry about an <code>instrument</code> for <code>0</code>. It's best to only include sounds for MIDI instruments that you need. Anything else is audio memory that could be better spent elsewhere, such as sound effects or higher-frequency samples.
 
For more information, review the N64 SDK Documentation at [http://n64devkit.square7.ch/pro-man/pro18/18-01.htm#02-01 18.1.2.1]. Note that the example for <code>bank</code> in the manual says to use <code>program</code> for referencing an <code>instrument</code>. This isn't correct and the <code>ic</code> tool will give you an error if <code>program</code> is used.
 
==== Percussion Sounds ====
Percussion in MIDI is a bit unique in that [https://en.wikipedia.org/wiki/General_MIDI#Percussion channel 10 is reserved for percussion], and each note maps to a specific instrument. "Middle C" is always a high bongo sound on the percussion channel.
 
To accommodate this, we create a special <code>instrument</code> for percussive sounds. Each different instrument will have its own <code>sound</code>, <code>envelope</code>, and <code>keymap</code> that only covers its corresponding key.
 
An example percussion setup for an Electric Base Drum (MIDI key <code>36</code>) might look like the following:
keymap Percussive_Bass_Drum_1Keymap
{
velocityMin = 0;
velocityMax = 127;
keyMin = 36;
keyMax = 36;
keyBase = 36;
detune = 0;
}
 
sound Percussive_Bass_Drum_1Sound
{
use ("electric_bass_drum_sample.aifc");
pan = 64;
volume = 127;
keymap = Percussive_Bass_Drum_1Keymap;
envelope = SomeBassDrumEnvelope;
}
 
Which would then integrate into an example percussion <code>instrument</code>:
instrument Percussion_Kit
{
volume = 127;
pan = 64;
 
sound = Percussive_Bass_Drum_1Sound;
sound = Percussive_Acoustic_SnareSound;
sound = Percussive_Low_TomSound;
sound = Percussive_Open_Hi_HatSound;
sound = Percussive_High_Mid_TomSound;
sound = Percussive_Crash_Cymbal_1Sound;
sound = Percussive_High_TomSound;
sound = Percussive_Ride_Cymbal_1Sound;
sound = Percussive_High_BongoSound;
sound = Percussive_Low_BongoSound;
sound = Percussive_CabasaSound;
sound = Percussive_MaracasSound;
sound = Percussive_ShakerSound;
}
 
The <code>bank</code> would then set <code>percussionDefault</code> to be <code>Percussion_Kit</code>.
 
==== AN64 verySDK simpleExample exampleInstrument Bank ====
The N64 SDK has reference Instrument Banks at <code>ultra/usr/src/pr/assets/banks</code>. If you're ever stuck on how something should look or are getting errors with <code>ic</code>, they can be a helpful guide to see how things are done.
TODO
 
==== Compiling the Instrument Bank ====
84

edits