Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7856457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:43:17+00:00 2026-06-02T20:43:17+00:00

How do I de-interleave the float *newAudio into float *channel1 and float* channel2 and

  • 0

How do I de-interleave the float *newAudio into float *channel1 and float* channel2 and interleave it back into newAudio?

Novocaine *audioManager = [Novocaine audioManager];

__block float *channel1;
__block float *channel2;
[audioManager setInputBlock:^(float *newAudio, UInt32 numSamples, UInt32 numChannels) {
  // Audio comes in interleaved, so, 
  // if numChannels = 2, newAudio[0] is channel 1, newAudio[1] is channel 2, newAudio[2] is channel 1, etc. 

      // Deinterleave with vDSP_ctoz()/vDSP_ztoz(); and fill channel1 and channel2
      // ... processing on channel1 & channel2
      // Interleave channel1 and channel2 with vDSP_ctoz()/vDSP_ztoz(); to newAudio
}];

What would these two lines of code look like? I don’t understand the syntax of ctoz/ztoz.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:43:18+00:00Added an answer on June 2, 2026 at 8:43 pm

    What I do in Novocaine’s accessory classes, like the Ringbuffer, for de-interleaving:

    float zero = 0.0;  
    vDSP_vsadd(data, numChannels, &zero, leftSampleData, 1, numFrames);   
    vDSP_vsadd(data+1, numChannels, &zero, rightSampleData, 1, numFrames);  
    

    for interleaving:

    float zero = 0.0;  
    vDSP_vsadd(leftSampleData, 1, &zero, data, numChannels, numFrames);   
    vDSP_vsadd(rightSampleData, 1, &zero, data+1, numChannels, numFrames);  
    

    The more general way to do things is to have an array of arrays, like

    int maxNumChannels = 2; 
    int maxNumFrames = 1024;
    float **arrays = (float **)calloc(maxNumChannels, sizeof(float *));  
    for (int i=0; i < maxNumChannels; ++i) {  
        arrays[i] = (float *)calloc(maxNumFrames, sizeof(float));
    }
    
    [[Novocaine audioManager] setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
        float zero = 0.0;
        for (int iChannel = 0; iChannel < numChannels; ++iChannel) {
            vDSP_vsadd(data, numChannels, &zero, arrays[iChannel], 1, numFrames);
        }
    }];
    

    which is what I use internally a lot in the RingBuffer accessory classes for Novocaine. I timed the speed of vDSP_vsadd versus memcpy, and (very, very surprisingly), there’s no speed difference.

    Of course, you can always just use a ring buffer, and save yourself the hassle

    #import "RingBuffer.h"
    
    int maxNumFrames = 4096
    int maxNumChannels = 2
    RingBuffer *ringBuffer = new RingBuffer(maxNumFrames, maxNumChannels)
    
    [[Novocaine audioManager] setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
        ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
    }];
    
    [[Novocaine audioManager] setOuputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
        ringBuffer->FetchInterleavedData(data, numFrames, numChannels);
    }];
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I need to interleave to strings into a singe list, yet am at
i am interested on this problem Interleave bits the obvious way (from http://graphics.stanford.edu/~seander/bithacks.html )
What is the most efficient way to de-interleave bits from a 32 bit int?
What is the best way to interleave a java String with a given character
What is a fast and simple implementation of interleave : console.log( interleave([1,2,3,4,5,6] ,2) );
In Python, is there a good way to interleave two lists of the same
I implement this interleave method in java but it doesn't work properly. Where is
When using OpenGL VBOs you can interleave your data You can even interleave vertex
This question: How to de-interleave bits (UnMortonizing?) has a good answer for extracting one
I'm trying to combine three signal waveforms into a single, interleaved waveform. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.