Drow::AudioFilePlayerExt audio distortion on iOS


#1

I'm trying to integrate drow audio into my app and am experiencing audio distortion on iOS only. Mac desktop is fine.

When playing back audio I get a strange reverb type distortion. If I change the AudioFilePlayerExt to a AudioFilePlayer then the audio sounds perfect although I have to comment out the filter calls in the setVolume call. I really would like to use AudioFilePlayerExt because I want to have access to the SoundTouch apis.

A related question is how do you set the volume on a plain old AudioFilePlayer object? (Not Ext)

Here is my interface...


class AudioPlayer : private AudioIODeviceCallback
{
public:
    AudioPlayer();
    ~AudioPlayer();
    
public:
    bool setFile(const File& file);
    void setVolume(double volume);
    void setPosition(double position);
    
    void start();
    void stop();
    
    bool isPlaying();
    
private:
    void audioDeviceAboutToStart(AudioIODevice* device);
    void audioDeviceStopped();
    void audioDeviceIOCallback(const float** inputChannelData,
                               int numInputChannels,
                               float** outputChannelData,
                               int numOutputChannels,
                               int numSamples);


private:
    AudioDeviceManager audioDeviceManager;
    AudioSourcePlayer audioSourcePlayer;
    AudioFilePlayerExt audioFilePlayer;
    BufferTransformAudioSource bufferTransformAudioSource;
};

 

And my implementation...

AudioPlayer::AudioPlayer()
    : bufferTransformAudioSource(&audioFilePlayer)
{
    audioDeviceManager.initialise(0, 2, nullptr, true);
    audioDeviceManager.addAudioCallback(this);
    audioSourcePlayer.setSource(&bufferTransformAudioSource);
}

AudioPlayer::~AudioPlayer()
{
    audioDeviceManager.removeAudioCallback(this);
    audioSourcePlayer.setSource(nullptr);
}

bool setFile(const File& file)
{
    return audioFilePlayer.setFile(file);
}

void AudioPlayer::setVolume(double volume)
{
    audioFilePlayer.setFilterGain(FilteringAudioSource::Low, (float)volume);
    audioFilePlayer.setFilterGain(FilteringAudioSource::Mid, (float)volume);
    audioFilePlayer.setFilterGain(FilteringAudioSource::High, (float)volume);
}

void AudioPlayer::setPosition(double position)
{
    audioFilePlayer.setPosition(position);
}

void AudioPlayer::start()
{
    audioFilePlayer.start();
}

void AudioPlayer::stop()
{
    audioFilePlayer.stop();
}

bool AudioPlayer::isPlaying()
{
    return audioFilePlayer.isPlaying();
}

void AudioPlayer::audioDeviceAboutToStart(AudioIODevice* device)
{
    audioSourcePlayer.audioDeviceAboutToStart(device);
}

void AudioPlayer::audioDeviceStopped()
{
    audioSourcePlayer.audioDeviceStopped();
}

void AudioPlayer::audioDeviceIOCallback(const float** inputChannelData,
                                        int numInputChannels,
                                        float** outputChannelData,
                                        int numOutputChannels,
                                        int numSamples)
{
    audioSourcePlayer.audioDeviceIOCallback(inputChannelData,
                                            numInputChannels,
                                            outputChannelData,
                                            numOutputChannels,
                                            numSamples);
}