AudioDataConverters deprecated

Can we get some examples on how to use the new juce::AudioData::ConverterInstance? Or some wrapper functions so the most common use cases remain as one liners?

Is this the correct update:

-juce::AudioDataConverters::convertInt16LEToFloat ( data, srcDataFloat, src.length );
+juce::AudioData::ConverterInstance<juce::AudioData::Pointer<juce::AudioData::Int16,   juce::AudioData::LittleEndian, AudioData::NonInterleaved, AudioData::Const>,
+juce::AudioData::Pointer<juce::AudioData::Float32, juce::AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::NonConst>> converter;
+
+converter.convertSamples ( srcDataFloat, data, src.length );

I’m struggling with the interlace one, is this correct`?

-juce::AudioDataConverters::interleaveSamples (src.getArrayOfReadPointers(), ilInputBuffer.getWritePointer (0), src.getNumSamples(), numChannels);
 
+juce::AudioData::ConverterInstance<juce::AudioData::Pointer<juce::AudioData::Float32, juce::AudioData::NativeEndian, juce::AudioData::NonInterleaved, juce::AudioData::Const>,
+juce::AudioData::Pointer<juce::AudioData::Float32, juce::AudioData::NativeEndian, juce::AudioData::Interleaved,    juce::AudioData::NonConst>> interleave (numChannels, numChannels);
+
+interleave.convertSamples ( ilInputBuffer.getWritePointer (0), src.getArrayOfReadPointers(), src.getNumSamples () );

It’s a bit more complex for interleaving/deinterleaving. I’ve added some helpers methods to the AudioData class for performing the conversions on the different AudioData sample and endianness types and there are some code examples for how to use the new API:

There’s also a more thorough example in the SIMDRegisterDemo:

1 Like