• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie question: mono playback to left or right speaker only?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question: mono playback to left or right speaker only?


  • Subject: Re: Newbie question: mono playback to left or right speaker only?
  • From: Jeremy Friesner <email@hidden>
  • Date: Tue, 13 Jan 2009 16:00:48 -0800

Hi Brad,

Thanks for the reply. Following your advice, I added this code to my program:

// Tell the Mac which speaker to emit sound from. We don't want it to emit from both!
struct AudioChannelLayout acl; memset(&acl, 0, sizeof(acl));
acl.mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelBitmap;
acl.mChannelBitmap = _isRightSpeaker ? kAudioChannelBit_Right : kAudioChannelBit_Left;
err = AudioUnitSetProperty(outputUnit, kAudioUnitProperty_AudioChannelLayout, kAudioUnitScope_Input, 0, &acl, sizeof(acl));
if (err) printf("Error setting audio unit channel! (%li)\n", (int32)err);
else printf("Set audio channel to %s.\n", _isRightSpeaker ? "right speaker" : "left speaker");


When I run that code, the AudioUnitSetProperty() call succeeds (i.e. "Set audio channel to left speaker" is printed), but audio is still heard from both of my speakers. Am I doing something wrong, above?

FWIW, I inserted the above code just before my call to AudioUnitInitialize(). I found that if I put it before my AudioUnitSetProperty(outputUnit, kAudioUnitProperty_StreamFormat, ...) call, the kAudioUnitProperty_AudioChannelLayout call would error out.

Thanks,
Jeremy


On Jan 12, 2009, at 11:11 AM, Brad Ford wrote:


On Jan 12, 2009, at 10:02 AM, Jeremy Friesner wrote:

Hi all,

I apologize if there is an obvious answer to this question, but after half an hour of scrounging around I haven't found anything.

Currently I have a program that uses CoreAudio (OpenAComponent(), AudioUnitSetProperty(), AudioOutputUnitStart(), etc) to play back a mono stream of audio. The program works fine, but currently it outputs the mono audio to both the left and right speaker of my Mac.

What I'd like to be able to is tell it to output the mono audio to only the left speaker, or only the right speaker.

Use kAudioUnitProperty_AudioChannelLayout + input scope to tell the audio unit that your source is Left or Right.


-Brad Ford
QuickTime Engineering



What's the best way to do this? Do I need to change my program to output a stereo stream, and make half of the stereo stream always be silent? Or is there a more clever/efficient way?

Thanks,
Jeremy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@apple.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Newbie question: mono playback to left or right speaker only?
      • From: Jeremy Friesner <email@hidden>
References: 
 >Newbie question: mono playback to left or right speaker only? (From: Jeremy Friesner <email@hidden>)
 >Re: Newbie question: mono playback to left or right speaker only? (From: Brad Ford <email@hidden>)

  • Prev by Date: Two projects I can't figure out- help?
  • Next by Date: Re: Two projects I can't figure out- help?
  • Previous by thread: Re: Newbie question: mono playback to left or right speaker only?
  • Next by thread: Re: Newbie question: mono playback to left or right speaker only?
  • Index(es):
    • Date
    • Thread