Q&A- mus Library

QA1 How do I use multiple sample banks?
QA2 How do I use multiple sound effect banks?
QA3 A floating point exception occurred inside an audio thread...
QA4 Nothing happens when I replace data with testmenu...
QA5 I get booted out when I initialize the library....
QA6 How do I make the MUS library compatible with an independent scheduler?
QA7 Problems occur when song data are memory sharing...
QA8 The maximum number of channels increases when I use MusHandlePause()...
QA9 Though there are enough channels, sometimes no sound can be heard. (199910)
QA10 Please tell me how to implement a monaural mode. (199908)


Q1 I understand I can use multiple sample bans, but how do I actually do that?

A1 Concretely speaking, simply set the default sample bank with the MusPtrBankSetCurrent() function. Don't forget to initialize the sample bank with the MusPtrBankInitialize() before specifying it.

Otherwise, there is also the MusPtrBankSetSingle() function. This is set in something called the override. It is characterized by having a higher priority than the default, but it is cleared after it is used one time. It can be used when you wish temporarily to switch to a sample bank for a specific song.

If you wish to utilize different banks for songs and sound effects, you could use MusFxBankSetPtrBank() to set the default value for each sound effect bank. However, keep in mind that the override will always take priority.

Please see the N64 Function Reference Manual for details about each function.

top


Q2 I've heard that you can use multiple files for sound effects, but how do you actually do that?

A2 Since Version 3, sound effect banks have been used instead of the C code as the sound effect source. As can be understood from the term "bank", these essentially are utilized in the same way as sample banks.

Concretely, reset the default with the MusFxBankSetCurrent() function. You can set a sound effect override with the MusFxBankSetSingle() function. An override takes priority over the default, but is cleared after it is used once, making it useful when you wish temporarily to switch sound effect banks.

In cases where there will be frequent switching between multiple sound effects and multiple sound effect banks, you may also set the default value for each bank with MusFxBankSetPtrBank().

Please see the N64 Function Reference Manual for details about each function.

top


Q3 When I try to pay a sound effect created with the N64 Sequencer with a dedicated sample bank initialized with the MusPtrBankIntialize() function, a floating point exception occurs in the audio thread and the program terminates.

The sample pointer bank data are loaded from ROM and the sample wave bank directly specifies the ROM address, but are there any restrictions on this?

A3 This is probably caused by the sound effect bank and sample bank not being properly combined. Even when only the sound effect is created on the N64 Sequencer, save it as a sng file.

When it is saved as an sfx file, there is a chance that it will not be able to synchronize since the sample bank information is not saved. sfx files are used when copying only the sound effect settings to other data. In addition, once you have saved the data as a sng file, run "Compile Bank" again.

top


Q4 I tried to play back trial data that I had created using testmenu, one of the sample programs included with N64 Sound Tools, but it didn't work very well. Does testmenu not work if you replace the data? Or is there some special setting that I should know about?

A4 With this testmenu, an area is statically set aside in RAM for bin files, ptr files and/or bfx files . Therefore, it becomes necessary to change the source when handling large bin files, ptr files, and/or bfx files.

Specifically, the size of the ptr files is set in Line 463 of test_main.c, while the sizes of bin files and bfx files are set in Lines 411~415. As the default here, tune_buffer1 and tune_buffer3 correspond with tune1 in the spec file, while tune_buffer2 and tune_buffer4 correspond with tune2. In addition, in the menu display, 1 indicates tune_buffer1, 2 indicates tune_buffer2, 3 indicates tune_buffer3, and 4 indicates tune_buffer4. This allows for easy changes.

[Line 463]
#define PBANK_SIZE	  5000

[Lines 411~415]
int tune_buffer1[6000/sizeof(int)];
int tune_buffer2[6000/sizeof(int)];
int tune_buffer3[6000/sizeof(int)];
int tune_buffer4[6000/sizeof(int)];
int sfx_buffer1[6000/sizeof(int)];

In addition, when changing the maximum number of channels or the playback frequency, please change the parameters in InitMusicPlayer() started from Line 470 of test_main.c.

top


Q5 I'm using the MUS library from NuSystem library. Previously I had no problem, but, when I initialized the sound after substituting the sound data, the sound dropped off.

Because the heap size defined in nualstl.h is larger than needed, I changed 0x80000 to 0x50000.

A5 The bin/ptr/bfx data areas are reserved in NuSystem from the audio heap. Therefore, since it seems that the audio heap is not large enough, try making the audio heap larger.

The method for calculating the required heap size is explained here.

First, the heap is reserved according to a parameter in the arguments when the library is initialized. You can check the size by the return value from the initialization function. Then, if the size reserved as the data area is enough, you can find the size of audio heap that is ultimately needed.

The nuAuStlHeapGetUsed() function, which tells the amount of audio heap being used, and the nuAuStlHeapGetFree() function, which gives the remaining free space, are also helpful.

top


Q6 How do I make the MUS library compatible with an independent scheduler.

A6 Use the MusSetScheduler() function to utilize an optional scheduler.

Specifically, consider nnsched, a sample program included with the N64 Sound Tools. This sample program makes it compatible with nnsched. Also consider that the library can be made compatible with the NuSystem scheduler with nuaustlmgrinit.c, which is one of the source files of NuSystem's nualstl.a file.

top


Q7 When I need to, I load sequence data (*.bin) into the same memory, but small problems come up when I switch songs.

Specifically, when I

depending on the song, either absolutely nothing will subsequently be played and/or graphics-related operations go funny.

When I tried inserting a suitable timer between stopping the song and loading the next data, everything went normally.

Is this standard?

A7 Yes.

When you stop a song with MusStop(), the song doesn't stop the instant that the function is called, but doesn't actually stop until the next frame (specifically, when the next audio frame is processed). Therefore, it is necessary to wait 1 frame before overwriting with DMA.

However, if MusStop() (or MusHandleStop()) has already been executed before the current MusStop() and a long fade-out is being performed, the second MusStop() will be ignored. In other words, the fade does not end until the number of frames specified by the first one have lapsed.

Therefore, use MusAsk() (or MusHandleAsk()) to check whether the previous one has ended.

top


Q8 A large number of channels are required when playing back another BGM while one BGM is temporarily stopped with the MusHandlePause()function. Is there a more efficient way of doing this?

A8 If the places where the BGM is being stopped are somewhat limited, there is a better way.

That is to set a synchronization marker in advance in the place where the BGM will be restarted, then use MusHandleStop() to stop BGM, and then restart it from MusStartSongFromMarker().

If there is somewhat of a shift at the stop location, this probably can be accommodated to some extent using fade-ins and fade-outs.

top


Q9 I played many SEs while playing the song; however, sometimes a part of the song could not be heard. Maybe there are not enough channels, but it seems that there are. What should I check?

A9 Probably one of the initialization parameters, "updates," is not sufficient. Try increasing the value of this parameter.

top


Q10 The API of MUS library does not have a function to switch to the monaural mode. Where should I modify to switch to a monaural?

I am using n_audio.

A10 In order to switch to a monaural, you need to modify the synthesizer. The portions in which pans are set in the library are shown below:

For the song (BGM), the 163rd line of n_env.c in the n_audio library.

  e->em_pan = param->pan; 

For SE, the 221st line of n_env.c in the n_audio library.

  e->em_pan = (s16) e->em_ctrlList->data.i; 

Please modify these portions so that the fixed value (64) is set when the monaural mode.

top