title: Core audio high CPU usage when no sound playing
body: <p>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.</p>
  
  <p>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 <code>AUGraph</code>. However, as more notes are played the CPU usage keeps increasing, even though no sound may be playing at the time.</p>
  
  <p>A timeline of this below:</p>
  
  <ol>
  <li>Starts app. Low to none CPU usage.</li>
  <li>Plays notes, medium CPU usage.</li>
  <li>Notes finish &amp; no sound playing, medium CPU usage.</li>
  </ol>
  
  <p>The code:</p>
  
  <pre><code>- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  {
      // Insert code here to initialize your application
  
      NewAUGraph(&amp;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, &amp;cd, 0, NULL, &amp;outputNode);
      AUGraphAddNode(audioGraph, &amp;cd, &amp;outputNode);
      //AUGraphGetNodeInfo(audioGraph, outputNode, 0, 0, 0, &amp;outputUnit);
      AUGraphNodeInfo(audioGraph, outputNode, &amp;cd, &amp;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, &amp;cd, &amp;mixerNode);
      AUGraphNodeInfo(audioGraph, mixerNode, &amp;cd, &amp;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, &amp;cd, &amp;synthNode);
      AUGraphNodeInfo(audioGraph, synthNode, &amp;cd, &amp;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);
  }
  </code></pre>
  
  <p>What's going on? How can I fix this?</p>
  
  <p>Thanks.</p>