Oh, I see now. Player() uses AudioPlayer(), and the API on AudioPlayer() does indeed indicate that after initialization (which presumably occurs during the first queue call) the audio_format properties can't be changed.
On Jan 10, 2:38 am, Mike Lawrence <[EMAIL PROTECTED]> wrote: > I'm finding that I cannot queue audio objects with different numbers > of channels to the same player. I don't see any mention in the API on > Player() that indicates this would be the case, so is this a bug? > > Here's code that should reproduce what I've found. Try queueing a > stereo source before a mono, or vice versa, and you find that only the > first queued event plays. > > from pyglet import media > from pyglet.media import Source, AudioFormat, AudioData, Player > from pyglet.media.procedural import ProceduralSource, Sine > from pyglet.clock import tick > import ctypes, os, math > > class stereo_Sine(ProceduralSource): > def __init__(self, duration, left, right, **kwargs): > super(stereo_Sine, self).__init__(duration*2, **kwargs) > self.left=left > self.right=right > self.audio_format.channels=2 > def _generate_data(self, bytes, offset): > if self._bytes_per_sample == 1: > start = offset > samples = bytes > bias = 127 > amplitude = 127.0 > channels = self.audio_format.channels > data = (ctypes.c_ubyte * (samples*channels))() > else: > start = offset >> 1 > samples = bytes >> 1 > bias = 0 > amplitude = 32767.0 > channels = self.audio_format.channels > data = (ctypes.c_short * (samples*channels))() > left_step = self.left * (math.pi * 2) / > self.audio_format.sample_rate > right_step = self.right * (math.pi * 2) / > self.audio_format.sample_rate > j=0 > for i in range(samples): > if i%2: > data[i] = int(math.sin(right_step * (j + > start)) * amplitude + > bias) > j=j+1 > else: > data[i] = int(math.sin(left_step * (j + > start)) * amplitude + > bias) > return data > > beep1=stereo_Sine(2,300,410) > beep2=Sine(2,410,300) > noise=WhiteNoise(4) > player=Player() > player.queue(beep1) > player.queue(beep2) > t=0 > tick() > player.play() > while t<4: > player.dispatch_events() > t=t+tick() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
