SGI Audio Tools: Difference between revisions

(Add instrument and bank information)
 
(11 intermediate revisions by the same user not shown)
Line 1:
== Introduction ==
The Nintendo 64 SDK comes with two "batteries included" audio libraries, the SGI Audio Tools and the N64SoundTools. The SGI Audio Tools are a collection of command-line tools for preparing samples and MIDI sequences for playback on the Nintendo 64. The N64SoundTools was written by Acclaim Studios Manchester (formerly Software Creations) and encompasses a kind of DAW for authoring and editing songs for the Nintendo 64.
TODO
 
This article hopes to give a step-by-step reference for authoring sounds and music with the SGI Audio Tools and playing them in a NuSystem-based game. While not as intuitive and straightforward as the N64SoundTools, there are advantages to having a collection of command-line tools as they're entirely scriptable and can help automate compiling/editing of sound data.
 
== Prerequisites ==
Line 34 ⟶ 36:
Programs such as [https://musescore.org/ MuseScore] likely export in Type 1, so it's usually a good idea to convert to Type 0 before continuing.
 
[[File:Midicvt_sample_image.png|frameless|Screenshot of <code>midicvt</code> run successfully.|alt=|500x500px]]
 
For each of your original MIDI files, run the following:
Line 46 ⟶ 48:
The NuSystem library is written to use compressed MIDI files for songs. If you inspect the library, you'll notice that it uses a <code> ALCSPlayer</code> for storing/playing songs. It is possible to use uncompressed Type 0 MIDI, but you'll need to look into editing/rebuilding NuSystem or your own audio code with Nintendo's core audio library.
 
[[File:Midicomp usage.png|frameless|Midicomp being successfully used.|alt=|600x600px]]
 
For each of your converted MIDI files, run the following:
Line 59 ⟶ 61:
<br ><code>sbc -Osongs.sbk first_song_compressed.cmf second_song_compressed.cmf third_song_compressed.cmf</code>
 
[[File:Sbc used.png|frameless|sbc successfully used here|alt=|600x600px]]
 
The '''ordering is important''' here! Keep note of the order of each parameter, as when you're selecting your songs in your game's source code, you'll be indexing them as they're ordered here (eg: <code>first_song_compressed.cmf</code> will be <code>0</code>, second_song_compressed.cmf </code> will be <code>1</code>, etc.).
Line 106 ⟶ 108:
* <code>envelope</code> section(s), indicating an [https://en.wikipedia.org/wiki/Envelope_(music) ADSR]
* <code>keymap</code> section(s), indicating the range of "piano keys" a sound occupies, as well as other data
* <code>sound</code> section(s), indicating a sampled sound andas well as the <code>envelope</code> and <code>keymap</code> it uses
* <code>instrument</code> section(s), indicating a "MIDI instrument" with a volume, pan, and various <code>sound</code>s
* A single <code>bank</code> section, indicating the sample rate, and which <code>instrument</code>s correspond to which MIDI instrument numbers in your sequences. This will include a specialized instrument for the drumset channel.
 
==== envelope ====
Line 147 ⟶ 149:
 
==== sound ====
A <code>sound</code> combines a <code>keymap</code>, <code>envelope</code>, and ana <code>aifc</code>compressed sample file together into a unit. A <code>sound</code> also has properties for stereo panning and volume from <code>0</code> to <code>127</code> each.
 
An example might look like:
Line 167 ⟶ 169:
 
An example <code>instrument</code> might look like:
 
instrument AnExampleInstrument
{
Line 173 ⟶ 176:
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>s. 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;
Line 204 ⟶ 206:
sampleRate = 32000;
percussionDefault = Percussion_Kit;
 
instrument [0] = AnExampleSound;
instrument [65] = AnExampleAltoSax;
Line 220 ⟶ 221:
 
==== 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 that each note maps to a specific instrument. "Middle C" has a note number of 60 which 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.
Line 249 ⟶ 250:
volume = 127;
pan = 64;
 
sound = Percussive_Bass_Drum_1Sound;
sound = Percussive_Acoustic_SnareSound;
Line 265:
}
 
The <code>bank</code> would then set <code>percussionDefault</code> to be <code>Percussion_Kit</code>.
 
==== N64 SDK Example Instrument Bank ====
Line 271:
 
==== Compiling the Instrument Bank ====
We use the instrument compiler program (<code>ic</code>) to turn our Instrument Bank file into <code>.tbl</code> and <code>.ctl</code> files for running ingame.
 
Run <code>ic</code> on your <code>.ins</code> file like the following:
ic -OSongBank SongBank.ins
Note that <code>SongBank</code> in this case whatever you called your <code>.ins</code> file. Also, note the lack of space before the <code>-O</code> argument. This seems to be correct for the tool.
 
If your <code>.ins</code> file doesn't have any errors, you should see an output like this:
 
[[File:Ic success.png|frameless|A bunch of garbled output from the instrument compiler, but no specific line numbers.|alt=|600x600px]]
 
You should also then have <code>.tbl</code> and <code>.ctl</code> files in the same directory with the name you put before the <code>-O</code> parameter.
 
[[File:Ic new files.png|frameless|The CTL and TBL output files shown via the DIR command.|alt=|500x500px]]
 
If there are syntax or other errors in your <code>.ins</code> file, you might get an error message like this:
 
[[File:Ic error.png|frameless|The instrument compiler showing an error.|alt=|600x600px]]
 
Even though the output looks garbled, try not to be discouraged! The final bit of output will show the line number of the error. The first place to look is often the associated line.
 
[[File:Screen Shot 2020-10-06 at 10.05.28 PM.png|frameless|An Instrument Bank file with a missing semicolon on line 28/29.|alt=|500x500px]]
 
In this case, the example error message was caused by a missing semicolon on line 28/29.
 
Much like the C-family of programming languages, semicolons indicate the start/end of statements. If you're missing one, the instrument compiler might associate two lines as a whole. Be sure to check the lines above and below if you're not initially sure where the error might be.
 
=== Finishing up ===
Line 280 ⟶ 305:
 
== Playing a song with NuSystem ==
TODO
 
=== Linking the Audio Library ===
TODO
 
=== Setting up playback ===
TODO
 
=== Starting/stoping playback ===
TODO
 
== Making an Instrument Bank for Sound Effects ==
TODO
 
=== Looping ===
==== Looping Compressed Audio ====
TODO
 
See [http://n64devkit.square7.ch/pro-man/pro20/20-05.htm#01 20.5] of the N64 SDK for more information on this.
 
==== Looping Non-Compressed Audio ====
As NuSystem is primarily compiled to use compressed sequenced audio, this is outside the scope of this article. However, [http://n64devkit.square7.ch/pro-man/pro17/17-03.htm#04 17.3.4] in the N64 SDK can help with non-compressed sequences.
84

edits