Programmer Sounds - Adding more than one sound.


(Luis Antonio) #1

As suggested we are using Programmer Sounds for dialogues and its working well.
We are now running into an issue where we want to build sentences out of more than one sound. (e.g. ‘Could you pass me the X’).

We have a separate file for each audio in the sentence so:
audio01 - Could you pass me the
audio02 - ObjectName

How would I go about loading 2 (or more) audio table sounds in code, into a programmer instrument, so I can make complex sentences?


(リチャード清水) #2

Hi Luis,

You can name the programmer instruments in the FMOD Studio project and get these names during the creation of the programmer sound callback.

https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD_STUDIO_PROGRAMMER_SOUND_PROPERTIES.html

Double click on the programmer instrument’s name (default will be “Programmer Instrument”) and give it a custom name. This will then be in the FMOD_STUDIO_PROGRAMMER_SOUND_PROPERTIES callback as the “name”.

You can then write functions to pass certain sounds into certain instruments.

Thanks,
Richard


(Luis Antonio) #3

Thanks for the reply, Richard.

But how would I use the callback to the programmer instrument name to queue 2 audio table sounds? (I’m already able to load one audio table sound into the programmer instrument. What I would like is to stack 2 of them and then start() the event knowing that it will end after playing both.

I’m looking at the provided example here:

https://www.fmod.com/resources/documentation-api?page=content/generated/engine_new_unity/script_example_programmersounds.html#/

Specifically the DialogueEventCallback() and if this part is the one where I could stack 2 audio table sounds:

case FMOD.Studio.EVENT_CALLBACK_TYPE.CREATE_PROGRAMMER_SOUND:
{
var parameter = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure(parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));
FMOD.Studio.SOUND_INFO dialogueSoundInfo;
var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo(key, out dialogueSoundInfo);
if (keyResult != FMOD.RESULT.OK){
break;
}

	FMOD.Sound dialogueSound;
	var soundResult = FMODUnity.RuntimeManager.LowlevelSystem.createSound(dialogueSoundInfo.name_or_data, dialogueSoundInfo.mode, ref dialogueSoundInfo.exinfo, out dialogueSound);
	if (soundResult == FMOD.RESULT.OK){
		parameter.sound = dialogueSound.handle;
		parameter.subsoundIndex = dialogueSoundInfo.subsoundindex;
		Marshal.StructureToPtr(parameter, parameterPtr, false);
	}
}
break;

(Luis Antonio) #4

Or are you suggesting that I add more than one programmer instrument to the event timeline, and load each sound to a separate programmer instrument? And if so, how would I make sure that the second one only starts when the first one is complete?


(リチャード清水) #5

Hi Luis,

Whilst it is possible to load or queue more than one audio file into a programmer instrument it is significantly more difficult than just to use two separate programmer instruments.

What would be even easier is to use a multi instrument set to loop once (in FMOD Studio 1.10.0 and later) with two programmer instruments with different names (right click on each and select Rename). This method will automatically play the two playlist items sequentially.

If you are using an earlier version of FMOD Studio then you can use a sustain point at the very end of the first programmer instrument (set to async) and query for when that programmer instrument has stopped playing (grab the FMOD::Sound’s channel and query isPlaying). When the instrument has stopped playing, you can release the sustain point to trigger the second instrument.

https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD_Channel_IsPlaying.html#/

Thanks,
Richard