Recorder.InputFactory must be specified if Recorder.Source set to Factory

I am having some issues with instantiating a custom audio recorder for my application. I've been following the steps in the FAQ (https://doc.photonengine.com/en-us/voice/current/troubleshooting/faq#how_to_use_a_custom_audio_source_) pretty well until I've come to step 3 where I need to create an instance of my class during app initialization. I am doing that, but I have no idea how to link it to the Photon Recorder. I made a clone of the sample AudioClipWrapper. I have been attempting to initialize it in a separate PhotonManager Script in its Start method, where I have this so far:

Recorder audioSource = new MyAudioReaderSource(audioClip);
recorder.InputFactory = (rec) => audioSource;

However, Visual Studio is saying that Delegate 'Func<IAudioDesc>' does not take 1 arguments. If anyone can explain to me a more detailed method of going about using the Factory input source type with Photon Voice, or knows how to remedy this issue would be much appreciated. I've searched high and low for this info but for whatever reason I can't seem to find it.

Comments

  • Hi @BrendanHutchins,

    Thank you for choosing Photon!

    The snippet on the doc is wrong, sorry about that we will fix it:

    it should be
    recorder.InputFactory = () => new MyAudioReaderSource();
    
    instead of
    Recorder.InputFactory = (rec) => new MyAudioReaderSource();
    

    besides, the following line looks wrong:
    Recorder audioSource = new MyAudioReaderSource(audioClip);
    

    So in your case all you need is:
    recorder.InputFactory = () => new MyAudioReaderSource(audioClip);
    
  • Thank you that works now! I'll message here if I have any more questions.
  • Ok so the error is gone, but for some reason the recorder.InputFactory is being created as null, therefore outputting the error "Recorder.InputFactory must be specified if Recorder.Source set to Factory". I am declaring the previously mentioned above phrase in an Awake method of one of my manager scripts, and have the Input Source Type of the Photon Recorder set to Factory
  • JohnTubeJohnTube mod
    edited February 19
    Hi @BrendanHutchins,

    Check if there is no exceptions thrown or errors logged.
    Make sure constructor works fine, here is another way of doing this where you could add checks and logs:
    private Recorder recorder;
    private AudioClip audioClip;
    
    private void Awake() {
        // this.audioClip = // get this
        // this.recorder = // get this
        recorder.InputFactory = MyCustomInputSourceFactory;
    }
    
    private IAudioDesc MyCustomInputSourceFactory() {
        MyAudioReaderSource myAudioSourceReader = new MyAudioReaderSource(this.audioClip);
        return myAudioSourceReader 
    }
    
  • Thanks for the response @JohnTube ! So I have done what you said and there appears to be a problem with converting the CustomAudioSource to the InputFactory on my end.
  • sorry
    use
    recorder.InputFactory = MyCustomInputSourceFactory;
    
    instead of
    recorder.InputFactory = MyCustomInputSourceFactory();
    
Sign In or Register to comment.