I’ve just started to use FMOD and I have some doubts about how to solve my issue. I’m instantiating GameObjects at runtime, these GameObjects are players, and according to some events, these players are modifying the value of the pitch of their voice.
The question is… Which is the best way to proceed with this? Should I create a new bus per player at runtime? This should be runtime groups? The idea is that each user will have its own pitch shifter, which I want to modify programmatically.
Thanks for your help!
Have a nice day!
There might be a simpler way to tackle this problem.
I would recommend adding an
Event Emitter (Unity Integration | Game Component - Studio Event Emitter) to the
Game Object that you are instantiating and then using
Parameters (FMOD Studio | Parameters) to
Automate (FMOD Studio | Authoring Events - Automation and Modulation) the pitch value for each player using the events.
Setting up the event like so:
You can then use the event emitter to change the parameter like so:
public FMODUnity.StudioEventEmitter emitter;
float randomPitchValue = 0;
// Where ever you instantiating the player you can assign the pitch parameter like so
Let me know if this solution will work.
Sorry for the late answer.
It works! I could manage to change the pitch through an event using parameters and automate pitch param, but… I have another question: is it possible to do the same but applying this to the microphone output from Photon voice instead from an audio file??
The process of getting FMOD to work with Photon is rather complex. An external example of how to set it up can be found on the Photon forums: Using FMOD with Photon Voice in Unity — Photon Engine. Let me know how you go about setting it up and if I can assist further.
I’m still doing test but no luck about this.
As said in the forum, I’ve tried to do the following steps:
Enable the define PHOTON_VOICE_FMOD_ENABLE
Modify Speaker.cs to use a FMODUnity.StudioEventEmitter instead of an AudioSource (and Photon.Voice.FMOD.AudioOutEvent instead of Photon.Voice.Unity.UnityAudioOut).
Make a looping programmer instrument event in FMOD (I made it 3 seconds long since that is how long buffer is created in AudioOut.cs)
But the audio is not played. I’m using the Photon Voice DemoVoiceUI for Unity.
I think I could manage to reproduce the Photon Voice through FMOD, but I think I’m missing something. After trying to follow the steps from the thread of the forum you’ve sent, it seems that I’m not able to apply the pitch shifter by code.
* the event contains "Programmer Instrument"
* Programmer Instrument is looped
* the event is persistent
* probably the event should be assigned to a bank
* fmod project is specified in unity fmod settings
* don't forget to run "build" in fmod studio after modifications
After following those steps and use SpeakerFMOD.cs instead of the one provided by photon, I think I’m doing something wrong with the audio because I’m receiving the following error:
[FMOD] ShadowEventInstance::createProgrammerSound : Programmer sound callback is not set for instrument ''.
[FMOD] EventInstance::createProgrammerSoundImpl : Programmer sound callback for instrument '' returned no sound.
I’ve been using this example.
Thanks for your help!
Could I get a code snippet of how you are retrieving the Photon Voice sound and then passing it to the programmer instrument to be played?
Another point to keep in mind the with programmer Instrument in your studio project is it will also need to be
async, this will allow it to play the whole audio passed to it.
Probably this is one of the problems, because I’ve changed the speaker to use the FMODSpeaker from Photon and adding an Event Emitter, but I don’t know exactly how this should send the audio to be treated by FMOD.
I’m just using this simple sample
but instead of the keys, I want to use the stream audio, but I don’t know exactly from where should I get that in the SpeakerFMOD to apply the event to it.
It seems that I made it work, but I don’t know which can be the reason for the sound to be cut every 3 seconds? I understand I have to set the programmer instrument forced to 3 seconds, async and loop but it seems the audio is cut.
I don’t know what can be wrong here.
Thanks for the support!
Good to hear it is working!
There may be a bit of confusion about
Looping Instruments (FMOD Studio | Working with Instruments - Looping Instruments) and
Loop Regions (FMOD Studio | Glossary - Loop Region)
If you right-click on the logic track you can add a
Loop Region which will keep the
async programmer instrument playing as long as the event is playing
Hope this helps!
Sorry to bother again. Apparently, the problem comes when I try to get the audio and send it to the programmer instrument.
[FMOD] EventInstance::createProgrammerSoundImpl : Programmer sound callback for instrument ‘’ returned no sound.
[FMOD] ShadowEventInstance::createProgrammerSound : Programmer sound callback is not set for instrument ‘’.
I’m still receiving these two warnings.
Right now, it is getting the value 0.5f from the pitch shifter, but it seems if I’m trying to change it using the SetParameterByName but nothing changes.
I’ve tried to modify it directly in the Speaker.cs in the Update pressing a key, but the pitch does not change. It seems the audio is not reaching to the Programmer Instrument but I don’t know exactly how the sound has to be sent.
Sorry about all the answers, apparently is already (definitely) working!
I don’t know if it is the best way to do it, but I’ve created a class that gets the audioOutEvent from the SpeakerFMOD.cs and use the setParameterByName as you said changing the pitch. In any case, I made different errors.
I didn’t know how to get the audio, from now, I’m getting it from FMODAudioOut (probably I have to change the way of doing this). From here, I’m getting the “PitchParam” (I don’t know why I could not access to it from a new callback).
CurrentInstance = new FMODLib.Studio.EventInstance(instance);
CurrentInstance.getParameterByName("PitchParam", out var value);
UnityEngine.Debug.Log("value: " + value);
Apart from that, I made a mistake trying to use the “Automation”, I’ve set it in the timeline instead creating the curve in the parameter.
Good to hear things are working. I am a bit confused, what wasn’t working at this time?