Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does naudiodon feed PCM data to portaudio? Interleaved or non-interleaved? #27

Open
tonetechnician opened this issue Apr 13, 2019 · 2 comments

Comments

@tonetechnician
Copy link

tonetechnician commented Apr 13, 2019

Hey there!

Hoping someone can clear this up for me, I've only just got into naudiodon and portaudio. Reading the portaudio c documentation, it says that it reads in multichannel pcm as interleaved or non-interleaved samples and 'automatically performs conversion where necessary'. I'm a bit confused how this concept applies within naudiodon.

Are we required to feed our multichannel files as interleaved or non-interleaved samples? I.e [chan1sampl0,chan2sampl0,chan3sampl0, chan1sampl1,chan2sampl1, chan3sampl1] or [chan1sampl0,chan1sampl1,chan2sampl0,chan2sampl1, chan3sampl0, chan3sampl1]?

Doing some tests, I see interleaving 8 bit samples seems to do the trick.

Now, when streaming more than 8 bit samples, how do we fill a buffer with the correct bytes for each sample? For instance, a 16 bit word, do we fill the buffer [upper16chan1sampl0,lower16chan1sampl0,upper16chan2sampl0,lower16chan1sampl0,... Etc ] or some other way?

Would appreciate any guidance with this!

@scriptorian
Copy link

Hi tonetechnician,

naudiodon doesn't attempt to do any kind of formatting of the audio data to or from portaudio. It expects interleaved samples for multichannel streams with the bit depth of each sample corresponding to the sample format specified in the options object. I think your 16-bit example looks about right - though you might need to check your endianness.

Good luck!

@tonetechnician
Copy link
Author

Thanks so much for the reply here.

Yes, I think there is a problem with my endianness. Have tried the above example and just get a nasty screech. Will look into it and post here once I've found out in case anyone else is wanting to know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants