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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:12:24+00:00 2026-05-23T16:12:24+00:00

I am just starting to learn Core Audio and made a simple test application

  • 0

I am just starting to learn Core Audio and made a simple test application the plays three different piano notes. It seems pretty good except for one small thing.

At first, the app uses about 7% or so of the CPU (visible in activity monitor), which I assume is normal because it is running a live AUGraph. However, as more notes are played the CPU usage keeps increasing, even though no sound may be playing at the time.

A timeline of this below:

  1. Starts app. Low to none CPU usage.
  2. Plays notes, medium CPU usage.
  3. Notes finish & no sound playing, medium CPU usage.

The code:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application

    NewAUGraph(&audioGraph);

    AudioComponentDescription cd;
    AUNode outputNode;
    AudioUnit outputUnit;

    cd.componentManufacturer = kAudioUnitManufacturer_Apple;
    cd.componentFlags = 0;
    cd.componentFlagsMask = 0;
    cd.componentType = kAudioUnitType_Output;
    cd.componentSubType = kAudioUnitSubType_DefaultOutput;

    //AUGraphNewNode(audioGraph, &cd, 0, NULL, &outputNode);
    AUGraphAddNode(audioGraph, &cd, &outputNode);
    //AUGraphGetNodeInfo(audioGraph, outputNode, 0, 0, 0, &outputUnit);
    AUGraphNodeInfo(audioGraph, outputNode, &cd, &outputUnit);

    AUNode mixerNode;
    AudioUnit mixerUnit;

    cd.componentManufacturer = kAudioUnitManufacturer_Apple;
    cd.componentFlags = 0;
    cd.componentFlagsMask = 0;
    cd.componentType = kAudioUnitType_Mixer;
    cd.componentSubType = kAudioUnitSubType_StereoMixer;

    AUGraphAddNode(audioGraph, &cd, &mixerNode);
    AUGraphNodeInfo(audioGraph, mixerNode, &cd, &mixerUnit);

    AUGraphConnectNodeInput(audioGraph, mixerNode, 0, outputNode, 0);

    AUGraphOpen(audioGraph);
    AUGraphInitialize(audioGraph);
    AUGraphStart(audioGraph);

    AUNode synthNode;


    cd.componentManufacturer = kAudioUnitManufacturer_Apple;
    cd.componentFlags = 0;
    cd.componentFlagsMask = 0;
    cd.componentType = kAudioUnitType_MusicDevice;
    cd.componentSubType = kAudioUnitSubType_DLSSynth;

    AUGraphAddNode(audioGraph, &cd, &synthNode);
    AUGraphNodeInfo(audioGraph, synthNode, &cd, &synthUnit);

    AUGraphConnectNodeInput(audioGraph, synthNode, 0, mixerNode, 0);

    AUGraphUpdate(audioGraph, NULL);
    CAShow(audioGraph);

}

- (IBAction)playMusic:(id)sender {
    MusicDeviceMIDIEvent(synthUnit, 0x90, 60, 127, 0);
    sleep(1);
    MusicDeviceMIDIEvent(synthUnit, 0x90, 62, 127, 0);
    sleep(1);
    MusicDeviceMIDIEvent(synthUnit, 0x90, 64, 127, 0);
}

- (void)one:(id)sender {
    MusicDeviceMIDIEvent(synthUnit, 0x90, 60, 127, 0);
}

- (void)two:(id)sender {
    MusicDeviceMIDIEvent(synthUnit, 0x90, 62, 127, 0);
}

- (void)three:(id)sender {
    MusicDeviceMIDIEvent(synthUnit, 0x90, 64, 127, 0);
}

What’s going on? How can I fix this?

Thanks.

  • 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-05-23T16:12:24+00:00Added an answer on May 23, 2026 at 4:12 pm

    Well, I figured it out!

    Basically, I was just forgetting to stop playing the notes, and although they tapered off into silence, they were still playing and making the computer work.

    This can be fixed by playing the note again with velocity set to 0. So, the code would look like this:

    - (IBAction)playMusic:(id)sender {
        MusicDeviceMIDIEvent(synthUnit, 0x90, 60, 127, 0);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 60, 0, 0);
        sleep(1);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 62, 127, 0);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 62, 0, 0);
        sleep(1);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 64, 127, 0);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 64, 0, 0);
    }
    
    - (void)one:(id)sender {
        MusicDeviceMIDIEvent(synthUnit, 0x90, 60, 127, 0);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 60, 0, 0);
    }
    
    - (void)two:(id)sender {
        MusicDeviceMIDIEvent(synthUnit, 0x90, 62, 127, 0);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 62, 0, 0);
    }
    
    - (void)three:(id)sender {
        MusicDeviceMIDIEvent(synthUnit, 0x90, 64, 127, 0);
        MusicDeviceMIDIEvent(synthUnit, 0x90, 64, 0, 0);
    }
    

    I guess if I wanted the note to play longer I could wait between starting and stopping the note.

    Thanks for all your help: @user757808 @Peter Hosey @mbykov

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

Sidebar

Related Questions

I'm just starting to learn the C programming language. I've written this simple piece
I am just starting to learn ruby. It seems that the default gems install
HI I am just starting to learn Core Data and one part that confuses
im just starting to learn flex and im trying to understand how Flex does
I am just starting to learn javascript, so I don't have the skills to
I am just starting to learn F#. In several F# coding examples I see
I'm just starting to learn C++ so you'll have to bear with my ignorance.
As someone who is just starting to learn the intricacies of computer debugging, for
I'm a C++ programmer just starting to learn Python. I'd like to know how
I am a Scala newbie, just starting to learn the language. I solved Problem

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.