Skip to main content
Inspiring
June 28, 2023
Answered

ConvertandInterleave corrupts my Transmit instance

  • June 28, 2023
  • 1 reply
  • 243 views

I'm trying to use the Transmitter template to transmit sound and image. I start by initializing and starting the plugin audio in the StartPlaybackClock() function, and later I fetch the relevant audio buffers in the PushVideo() function. 

 

The problem arises when I try to convert the resulting mAudioBuffers into an interleaved single buffer using this PrSdkAudioSuite function 

mSuites.AudioSuite->ConvertAndInterleaveTo32BitInteger(float** inSource, short* inDestination, unsigned int inNumChannels, unsigned int inNumSampleFrames)

 

assuming inSource is simple mAudioBuffers, the only point of contention is the inDestination, which I was only able to make work using a variable array defined as  short* interleavedbuffer[32]; Just using a normal short* would result in an illegal parameter error.

 

Using this function totally breaks my transmit instance, changing the value of pretty much all of my variables, like setting my frame width and height parameters to 319756362 and my NumSampleFrames variable to be 535503260, and also changing the address of every reference contained in the transmitinstance. This issue also occured with trying to interleave to a 16 bit integer.

This topic has been closed for replies.
Correct answer Leonard30161191pug2

I just realized and solved my error. It lied with the definition of my interleaving destination buffer. I set it to be an array of length 32, but since every element of the array is a single frame of sound, and not a full channel like for the source buffer, its length actually needs to be (number of channels * number of sample frames), and trying to fit the data into a buffer too small is bound to create some wacky consequences.

1 reply

Leonard30161191pug2AuthorCorrect answer
Inspiring
June 29, 2023

I just realized and solved my error. It lied with the definition of my interleaving destination buffer. I set it to be an array of length 32, but since every element of the array is a single frame of sound, and not a full channel like for the source buffer, its length actually needs to be (number of channels * number of sample frames), and trying to fit the data into a buffer too small is bound to create some wacky consequences.