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 8360825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:33:28+00:00 2026-06-09T11:33:28+00:00

Is it possible to phase shift audio in real time on the iPhone? I

  • 0

Is it possible to phase shift audio in real time on the iPhone?

I have a simple application set up that outputs the audio from the microphone in real time. What I am trying to do is process this audio i.e. Do a phase shift.

Am I correct the only way to proceed is to take my sample space, do a FFT, phase shift, and then inverse fft?

I am aware of the vDSP library but it seems like too much overhead for a simple task.

UPDATE: I have a grounding in DSP from Elec Eng, and yes I really do want to do a phase shift. I do not need to do a freq shift or filter, they are seperate process’s I will later implement.

  • 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-09T11:33:29+00:00Added an answer on June 9, 2026 at 11:33 am

    Yep, that’s a way to do it.

    This sample C code shows it:

    #include <stdio.h>
    #include <math.h>
    
    #ifndef M_PI
    #define M_PI 3.14159265358979324
    #endif
    
    typedef struct
    {
      double x, y;
    } tComplex;
    
    tComplex complexAdd(const tComplex* a, const tComplex* b)
    {
      tComplex c;
      c.x = a->x + b->x;
      c.y = a->y + b->y;
      return c;
    }
    
    tComplex complexMul(const tComplex* a, const tComplex* b)
    {
      tComplex c;
      c.x = a->x * b->x - a->y * b->y;
      c.y = a->x * b->y + a->y * b->x;
      return c;
    }
    
    void dft(tComplex out[], const tComplex in[], size_t n, int direction)
    {
      size_t k, i;
      for (k = 0; k < n; k++)
      {
        tComplex r = { 0, 0 }, e;
        for (i = 0; i < n; i++)
        {
          e.x = cos(-2 * direction * M_PI / n * ((double)k - n / 2) * ((double)i - n / 2));
          e.y = sin(-2 * direction * M_PI / n * ((double)k - n / 2) * ((double)i - n / 2));
          e = complexMul(&e, &in[i]);
          r = complexAdd(&r, &e);
        }
        out[k] = r;
      }
    }
    
    double maxAbs(const tComplex in[], size_t n)
    {
      double m = 0;
      while (n--)
      {
        double a = hypot(in->x, in->y);
        if (m < a) m = a;
        in++;
      }
      return m;
    }
    
    #define SAMPLE_CNT   32
    #define SAMPLE_SHIFT 3
    
    int main(void)
    {
      tComplex signalIn[SAMPLE_CNT];
      tComplex signalOut[SAMPLE_CNT];
      tComplex tmp[SAMPLE_CNT];
      int i;
    
      // signalIn[] = square pulse
      for (i = 0; i < SAMPLE_CNT; i++)
      {
        signalIn[i].x = ((i - SAMPLE_CNT / 2) >= 0) * ((i - SAMPLE_CNT / 2) < SAMPLE_CNT / 4);
        signalIn[i].y = 0;
      }
    
      // tmp[] = DFT{signalIn[]}
      dft(tmp, signalIn, SAMPLE_CNT, 1);
    
      // tmp[] = DFT{signalIn[]} * exp(j * 2 * PI * f * TimeShift)
      for (i = 0; i < SAMPLE_CNT; i++)
      {
        tComplex e;
        e.x =  cos(2 * M_PI * (i - SAMPLE_CNT / 2) * SAMPLE_SHIFT / SAMPLE_CNT);
        e.y = -sin(2 * M_PI * (i - SAMPLE_CNT / 2) * SAMPLE_SHIFT / SAMPLE_CNT);
        tmp[i] = complexMul(&tmp[i], &e);
      }
    
      // signalOut[] = IDFT{tmp[]}
      dft(signalOut, tmp, SAMPLE_CNT, -1);
    
      printf("     Re{In[]}    .     Im{In[]}    |"
             "   |DFT{In[]}|   |"
             "    Re{Out[]}    .    Im{Out[]}\n");
    
      for (i = 0; i < SAMPLE_CNT; i++)
      {
        int j, s;
    
        s = signalIn[i].x / maxAbs(signalIn, SAMPLE_CNT) * 8 + .5;
        for (j = -8; j <= 8; j++) printf("%c", " *"[s == j]);
        printf(".");
        s = signalIn[i].y / maxAbs(signalIn, SAMPLE_CNT) * 8 + .5;
        for (j = -8; j <= 8; j++) printf("%c", " *"[s == j]);
    
        printf("|");
    
        s = hypot(tmp[i].x, tmp[i].y) / maxAbs(tmp, SAMPLE_CNT) * 8;
        for (j = -8; j <= 8; j++) printf("%c", " *"[s == j]);
    
        printf("|");
    
        s = signalOut[i].x / maxAbs(signalOut, SAMPLE_CNT) * 8 + .5;
        for (j = -8; j <= 8; j++) printf("%c", " *"[s == j]);
        printf(".");
        s = signalOut[i].y / maxAbs(signalOut, SAMPLE_CNT) * 8 + .5;
        for (j = -8; j <= 8; j++) printf("%c", " *"[s == j]);
    
        printf("\n");
      }
    
      return 0;
    }
    

    Output:

         Re{In[]}    .     Im{In[]}    |   |DFT{In[]}|   |    Re{Out[]}    .    Im{Out[]}
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |          *      |        *        .        *        
            *        .        *        |             *   |        *        .        *        
            *        .        *        |               * |        *        .        *        
                    *.        *        |                *|        *        .        *        
                    *.        *        |               * |        *        .        *        
                    *.        *        |             *   |        *        .        *        
                    *.        *        |          *      |                *.        *        
                    *.        *        |        *        |                *.        *        
                    *.        *        |         *       |                *.        *        
                    *.        *        |         *       |                *.        *        
                    *.        *        |         *       |                *.        *        
            *        .        *        |        *        |                *.        *        
            *        .        *        |        *        |                *.        *        
            *        .        *        |         *       |                *.        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
    

    You can see that the output is a replica of the input shifted by SAMPLE_SHIFT samples (3, here) in time.

    You can change SAMPLE_SHIFT to a non-integer value too, getting a shift by a fractional number of samples.

    Output for SAMPLE_SHIFT = 2.5:

         Re{In[]}    .     Im{In[]}    |   |DFT{In[]}|   |    Re{Out[]}    .    Im{Out[]}
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |          *      |        *        .        *        
            *        .        *        |             *   |        *        .        *        
            *        .        *        |               * |        *        .        *        
                    *.        *        |                *|        *        .        *        
                    *.        *        |               * |        *        .        *        
                    *.        *        |             *   |           *     .        *        
                    *.        *        |          *      |                *.        *        
                    *.        *        |        *        |              *  .        *        
                    *.        *        |         *       |               * .        *        
                    *.        *        |         *       |              *  .        *        
                    *.        *        |         *       |               * .        *        
            *        .        *        |        *        |              *  .        *        
            *        .        *        |        *        |                *.        *        
            *        .        *        |         *       |           *     .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |        *        |        *        .        *        
            *        .        *        |         *       |        *        .        *        
            *        .        *        |        *        |        *        .        *        
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this application that consists of two phases. Queuing phase and chatting Phase.
I have been using a Phase Listener to debug my JSF application. Now I'm
I am in the design phase of writing a new Windows service application that
I'm at the debugging/optimization phase with an iPhone app. I have one bottleneck left
I'm fairly certain that this isn't possible but I thought I'd ask. The iPhone
Is it possible to copy some values from render (or better action) phase to
I have a maven plugin that should run in the compile phase, so in
I have an Mac Application, and when I launch it the first time, a
Is it possible to remove a file using a build phase in xcode 4
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way

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.