Hey all -
I'm trying to interface the code found in output-example2.c with the Qt
library and it's audio input class.
I've got the Qt side of the code feeding audio data (44100 freq, 1 chan, 16
bit samples) into a buffer that's basically a char* array (a QByteArray if
anyone cares.)
I've having trouble converting the data from the char* array (which I know
is 16bit audio data) into the int16_t* pointer passed to get_audio_frame().
Function signature below as a refresher:
static void get_audio_frame(int16_t *samples, int frame_size, int
nb_channels);
Basically, what I've done so far is:
QByteArray byteArray; // defined elsewhere in the code...
char *bufferFromQt = byteArray.data();
int sizeOfBufferFromQt = byteArray.size();
// I'm sure there's better/smarter ways of finding bytesToCopy...
int bytesToCopy = qMin(frame_size*2, sizeOfBufferFromQt);
// This is where the problem is...right? What should I do here?
memcpy(samples, bufferFromQt, bytesToCopy);
I can provide a sample .wav/.avi file encoded with the code from
output-example2.c and the Qt audio recording code if anyone cares, but it
basically sounds like a bunch of static punctured by small bouts of
silence.
I also tried (obviously a hacked version of the original sine-wave audio
generator code):
int dCounter=0, sz = sizeOfBufferFromQt;
char *data = bufferFromQt;
int j, i, v;
int16_t *q = samples;
for(j=0;j<frame_size;j++) {
//v = (int)(sin(t) * 10000);
v = 0;
if(dCounter < sz - 2)
{
memcpy(&v, data, 2);
*data += 2;
dCounter += 2;
}
for(i = 0; i < nb_channels; i++)
*q++ = v;
t += tincr;
tincr += tincr2;
}
That version didn't do any good either - same basic audio output
(mores-code static) - nothing like what it should sound like.
I'm sure I'm not converting from char* to int16_t* right somehwere - but I
can't figure out how. Any advice?
Thanks!
-Josiah
--
Josiah Bryan
765-215-0511
[email protected]
_______________________________________________
libav-api mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-api