Code Monkey home page Code Monkey logo

Comments (31)

alexbw avatar alexbw commented on July 26, 2024

That'd be weird. I thought I always let the device decide what to output...

On Tue, Aug 14, 2012 at 2:38 PM, Morgan Packard [email protected]:

Am I crazy? Has this always been the case and nobody noticed until now?
Novocaine is outputting audio in mono through headphones.
ioData->mBuffers[0].mNumberChannels is 1.

If I figure out why, I'll make a note, and, with luck and a good attitude,
commit some code.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Just downloaded Novocaine fresh from github to make sure and am getting only one channel of TLC.

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

What in the what
Goshdarnit

On Tue, Aug 14, 2012 at 2:59 PM, Morgan Packard [email protected]:

Just downloaded Novocaine fresh from github to make sure and am getting
only one channel of TLC.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-7736377.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

I'm not sure I trust the ASBD that the iPhone provides. After this bit:

// Check the input stream format

# if defined ( USING_IOS )
UInt32 size;
size = sizeof( AudioStreamBasicDescription );
CheckError( AudioUnitGetProperty( inputUnit, 
                                 kAudioUnitProperty_StreamFormat, 
                                 kAudioUnitScope_Input, 
                                 1, 
                                 &inputFormat, 
                                 &size ), 

inputFormat.mNumberChannels is 2. I'd expect it to be 1.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

also after this bit:

CheckError(AudioUnitSetProperty(inputUnit,
                                kAudioUnitProperty_StreamFormat,
                                kAudioUnitScope_Output,
                                kInputBus,
                                &outputFormat,
                                size),
           "Couldn't set the ASBD on the audio unit (after setting its sampling rate)");

inputFormat.mNumberChannels is 2. I tried explicitly setting the ASBD for kAudioUnitScope_Input, bus 0, which seems like it should control the number of channels in the render callback, but it had no effect. I also threw my phone out the window, and that didn't help either. I will toss my computer after it and see if that helps.

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Gosh diggity darn it
You getting stereo out of the iPod app?

On Tue, Aug 14, 2012 at 3:13 PM, Morgan Packard [email protected]:

also after this bit:

CheckError(AudioUnitSetProperty(inputUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
kInputBus,
&outputFormat,
size),
"Couldn't set the ASBD on the audio unit (after setting its sampling rate)");

inputFormat.mNumberChannels is 2. I tried explicitly setting the ASBD for
kAudioUnitScope_Input, bus 0, which seems like it should control the number
of channels in the render callback, but it had no effect. I also threw my
phone out the window, and that didn't help either. I will toss my computer
after it and see if that helps.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-7736826.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Mono out of my phone running the demo ios app in the latest from github, stereo from simulator (running an older version of novocaine, but I suspect a newer would also be stereo).

My phone is working correctly. I'm getting audio in stereo from other apps.

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Aight. Gotta think about that.

On Tue, Aug 14, 2012 at 3:24 PM, Morgan Packard [email protected]:

Mono out of my phone running the demo ios app in the latest from github,
stereo from simulator (running an older version of novocaine, but I suspect
a newer would also be stereo).

My phone is working correctly. I'm getting audio in stereo from other apps.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-7737150.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

I will do the same.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Closing in on the problem (maybe). Looks like the render callback is expecting non-interleaved data. Does that square with your understanding Alex? I'm going to take a closer look and see if that could explain why the audio is coming through clean, but mono.

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Interesting. The render callback was designed to always ask for interleaved data, and then inside the machinery of Novocaine, everything gets massaged into exactly what the hardware expects, which can be any number of things (interleaved, non-interleaved, mono, stereo, SInt16 or float).

On Aug 15, 2012, at 9:29 AM, Morgan Packard wrote:

Closing in on the problem (maybe). Looks like the render callback is expecting non-interleaved data. Does that square with your understanding Alex? I'm going to take a closer look and see if that could explain why the audio is coming through clean, but mono.


Reply to this email directly or view it on GitHub.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Ok, so my previous comment about knowing things are busted because ioData->mBuffers[0].mNumberChannels is 1 may not indicate a problem. mNumberChannels indicates the number of interleaved channels.

Next potential problem:

        int thisNumChannels = ioData->mBuffers[iBuffer].mNumberChannels;

        for (int iChannel = 0; iChannel < thisNumChannels; ++iChannel) {
            vDSP_vsadd(sm.outData+iChannel, sm.numOutputChannels, &zero, (float *)ioData->mBuffers[iBuffer].mData, thisNumChannels, inNumberFrames);
        }

Even if thisNumChannels was 2, the starting point on the destination buffer is ioData->mBuffers[iBuffer].mData on every iteration. Wouldn't successive iterations just overwrite data in the same place here? Based on what I"m seeing here and what I think I understand, I'd expect the audio to be either noise/glitch in the right channel, or maybe pitched 2x too fast, but I'm hearing clean audio, just the same in each channel.

EDIT

Nevermind. Bear with me while I de-stupid myself.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Still keep ignoring me please.

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

On it

On Wed, Aug 15, 2012 at 10:35 AM, Morgan Packard
[email protected]:

Still keep ignoring me please.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-7757402.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Ok. Found the problem. Give me a cookie.

    for (int iBuffer=0; iBuffer < ioData->mNumberBuffers; ++iBuffer) {  

        int thisNumChannels = ioData->mBuffers[iBuffer].mNumberChannels;

        for (int iChannel = 0; iChannel < thisNumChannels; ++iChannel) {
            vDSP_vsadd(sm.outData+iChannel, sm.numOutputChannels, &zero, (float *)ioData->mBuffers[iBuffer].mData, thisNumChannels, inNumberFrames);
        }
    }

With interleaved data, thisNumChannels is 1 and ioData->mNumberBuffers is 2. If the data is non-interleaved, we loop through the outer loop twice and the inner loop once. If it's interleaved, the opposite happens. Either way, for a stereo signal, vDSP_vsadd gets called twice. We need to get the correct start point on sm.outData. If thisNumChannels is 2 and mNumberBuffers is 1, this works fine, but if thisNumChannels is 1 and mNumberBuffers is 2, we start at the very first sample every time in sm.outData. Adding iBuffer to the pointer offset in vDSP_vsadd fixes the problem in my particular case. Don't know what it might break in other cases though.

vDSP_vsadd(sm.outData+iChannel+iBuffer, sm.numOutputChannels, &zero, (float *)ioData->mBuffers[iBuffer].mData, thisNumChannels, inNumberFrames);

from novocaine.

bordev avatar bordev commented on July 26, 2024

thanks morganpackard for saving lots of time 👍

from novocaine.

ndonald2 avatar ndonald2 commented on July 26, 2024

Reviving an old thread, but there still seems to be a problem with stereo non-interleaved output on iOS devices, at least with iPhone 4/iOS6.

The problem lies here:

for (int iBuffer=0; iBuffer < ioData->mNumberBuffers; ++iBuffer) {

    int thisNumChannels = ioData->mBuffers[iBuffer].mNumberChannels;

    for (int iChannel = 0; iChannel < thisNumChannels; ++iChannel) {
        vDSP_vfix16(sm.outData+iChannel, sm.numOutputChannels, (SInt16 *)ioData->mBuffers[iBuffer].mData+iChannel, thisNumChannels, inNumberFrames);
    }
}

For non-interleaved stereo output, there will be 2 mBuffers each with one channel of non-interleaved output. The existing code will loop through both of these, but copies the first (left) channel from the interleaved sm.outData to each output channel, since iChannel will never be larger than 0.

Fix is something like this:

if (sm.isInterleaved){

    for (int iBuffer=0; iBuffer < ioData->mNumberBuffers; ++iBuffer) {  

        int thisNumChannels = ioData->mBuffers[iBuffer].mNumberChannels;

        for (int iChannel = 0; iChannel < thisNumChannels; ++iChannel) {
            vDSP_vsadd(sm.outData+iChannel, sm.numOutputChannels, &zero, (float *)ioData->mBuffers[iBuffer].mData, thisNumChannels, inNumberFrames);
        }
    }
}
else{
    for (int iChannel = 0; iChannel < sm.numOutputChannels; iChannel++){
      if (iChannel > ioData->mNumberBuffers) break; // this shouldn't happen
      vDSP_vsadd(sm.outData+iChannel, sm.numOutputChannels, &zero, (float *)ioData->mBuffers[iChannel].mData, 1, inNumberFrames);
    }
}

The break statement is a safeguard but unless CoreAudio is reporting incorrect format info, it should never happen.

I have it working on another project (collab with @morganpackard actually). Happy to submit a pull request if this looks good.

from novocaine.

ndonald2 avatar ndonald2 commented on July 26, 2024

Or what morgan said 7 months ago also works...

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

I would totally love a pull request. Nick and Morgan — you guys are some of
the most active users of Novocaine, do either of you want to be able to
contribute directly to the project?
My involvement has dipped significantly because of other obligations.
Would love to have some other devs onboard as contributors.

On Wed, Mar 20, 2013 at 7:41 PM, Nick D. [email protected] wrote:

Or what morgan said 7 months ago also works...


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-15211054
.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

I don't see why not. I'll be gentle, I promise.
-m-

On Wed, Mar 20, 2013 at 8:52 PM, Alex Wiltschko [email protected]:

I would totally love a pull request. Nick and Morgan — you guys are some
of
the most active users of Novocaine, do either of you want to be able to
contribute directly to the project?
My involvement has dipped significantly because of other obligations.
Would love to have some other devs onboard as contributors.

On Wed, Mar 20, 2013 at 7:41 PM, Nick D. [email protected]
wrote:

Or what morgan said 7 months ago also works...


Reply to this email directly or view it on GitHub<
https://github.com/alexbw/novocaine/issues/28#issuecomment-15211054>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-15213556
.

Morgan Packard
cell: (720) 891-0122
aim: mpackardatwork
twitter: @morganpackard

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Ok Morgan and Nick. You're contributors and stewards. Nick, we haven't met (I don't think...) but Morgan says you're a smarty pants and a half, so you're in too.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Thanks Alex!

Sent from my iPhone

On Mar 24, 2013, at 6:23 PM, Alex Wiltschko [email protected]
wrote:

Ok Morgan and Nick. You're contributors and stewards. Nick, we haven't met
(I don't think...) but Morgan says you're a smarty pants and a half, so
you're in too.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/28#issuecomment-15370802
.

from novocaine.

dwsolberg avatar dwsolberg commented on July 26, 2024

I"m experiencing this same problem.

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Morgan, if you find the time, can you pull in your changes that fix this?

On Fri, Mar 29, 2013 at 12:17 PM, David Solberg [email protected]:

I"m experiencing this same problem.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-15648135
.

from novocaine.

 avatar commented on July 26, 2024

Sorry, how can I unsubscribe from this list?

On Mar 29, 2013, at 12:18 PM, Alex Wiltschko [email protected] wrote:

Morgan, if you find the time, can you pull in your changes that fix this?

On Fri, Mar 29, 2013 at 12:17 PM, David Solberg [email protected]:

I"m experiencing this same problem.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-15648135
.


Reply to this email directly or view it on GitHub.

Hans Tutschku
www.tutschku.com

from novocaine.

dwsolberg avatar dwsolberg commented on July 26, 2024

FYI, either suggested fix worked for me on an iPad with iOS 6 using a .m4a file.

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

Will do.

On Fri, Mar 29, 2013 at 12:18 PM, Alex Wiltschko
[email protected]:

Morgan, if you find the time, can you pull in your changes that fix this?

On Fri, Mar 29, 2013 at 12:17 PM, David Solberg [email protected]:

I"m experiencing this same problem.


Reply to this email directly or view it on GitHub<
https://github.com/alexbw/novocaine/issues/28#issuecomment-15648135>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-15648204
.

Morgan Packard
cell: (720) 891-0122
aim: mpackardatwork
twitter: @morganpackard

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Is this pulled in yet?

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

@morganpackard Is this a dead issue?

from novocaine.

morganpackard avatar morganpackard commented on July 26, 2024

I think so.

Sent from my iPhone

On Nov 14, 2013, at 11:36 PM, Alex Wiltschko [email protected]
wrote:

@morganpackard https://github.com/morganpackard Is this a dead issue?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/28#issuecomment-28546840
.

from novocaine.

MohdFarhanKhan avatar MohdFarhanKhan commented on July 26, 2024

Hi,

Am novocain addicted new ios developer. Am using novocain in an ios project. App is recording 2 channel audio. Client records audio with a sensor device. That sensor also can work as receiver. Client's requirement is to send a tone to sensor not speaker while recording from sensor. Please help me how to send tone to sensor.

from novocaine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.