It's on OSX right now.

>>> pyglet.options['audio']
('directsound', 'openal', 'alsa', 'silent')

The example I gave isn't the right one, and I haven't got a more
minimal example yet.

Thanks

On Mar 6, 8:36 pm, "Alex Holkner" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 7, 2008 at 10:37 AM, hagna <[EMAIL PROTECTED]> wrote:
>
> >  Get the code without breaks here -->http://dpaste.com/38321/
>
> >  On Mar 6, 4:36 pm, hagna <[EMAIL PROTECTED]> wrote:
> >  > This duplicates the bad behavior:
>
> >  > from pyglet import media
> >  > from pyglet.media import procedural, AudioData
> >  > from ctypes import *
> >  > import sys
> >  > from pyglet import font, window, media, clock
> >  > from pyglet.gl import *
> >  > from pyglet.window import event, key
>
> >  > class cw_sound(object):
> >  >     def __init__(self, msg='CQ', wpm=5, fwpm=15):
> >  >         self.chWPM(wpm, fwpm)
> >  >         self.msg = msg
>
> >  >     _code = {'A':'.-',          'N':'-.',          '1':'.----',
> >  > '.':'.-.-.-',
> >  >         'B':'-...',        'O':'---',         '2':'..---',
> >  > ',':'--..--',
> >  >         'C':'-.-.',        'P':'.--.',        '3':'...--',
> >  > '?':'..--..',
> >  >         'D':'-..',         'Q':'--.-',        '4':'....-',
> >  > '(':'-.--.',
> >  >         'E':'.',       'R':'.-.',         '5':'.....',
> >  > '-':'-....-',
> >  >         'F':'..-.',        'S':'...',         '6':'-....',
> >  >         'G':'--.',         'T':'-','7':'--...',
> >  >         'H':'....',        'U':'..-',         '8':'---..',
> >  >         'I':'..',          'V':'...-',        '9':'----.',
> >  >         'J':'.---',        'W':'.--',         '0':'-----',
> >  >         'K':'-.-',         'X':'-..-',        '/':'-..-.',
> >  >         'L':'.-..',        'Y':'-.--',        '+':'.-.-.',
> >  >         'M':'--',          'Z':'--..',        '=':'-...-'}
>
> >  >     def addWPM(self, m):
> >  >         self.wpm += m
> >  >         self.wpm = max(5, self.wpm)
> >  >         self.wpm = min(self.wpm, 60)
> >  >         self.fwpm += m
> >  >         self.fwpm = max(5, self.fwpm)
> >  >         self.fwpm = min(self.fwpm, 60)
> >  >         self.chWPM(self.wpm, self.fwpm)
>
> >  >     def chWPM(self, wpm, fwpm):
> >  >         """I took this from morse-2.1"""
> >  >         self.wpm = wpm
> >  >         self.fwpm = fwpm
> >  >         tick = 60 / float((wpm * 50))
> >  >         if (fwpm <= wpm):
> >  >             ftick = 60 / float((wpm * 50))
> >  >         else:
> >  >             ftick = 60 / float((fwpm * 50))
>
> >  >         wtick = (50 * tick - 31 * ftick) / float(19)
>
> >  >         self.inter_char_time = wtick * 3
> >  >         self.inter_word_time = wtick * 7
>
> >  >         self.intra_char_time = ftick
> >  >         self.dot_time = ftick
> >  >         self.dash_time = ftick * 3
>
> >  >         self.freq = 800
> >  >         self.dahsound = (procedural.Sine(self.dash_time, self.freq))
> >  >         self.ditsound = (procedural.Sine(self.dot_time, self.freq))
> >  >         self.intrachar_silence =
> >  > (procedural.Silence(self.intra_char_time))
> >  >         self.interchar_silence =
> >  > (procedural.Silence(self.inter_char_time))
> >  >         self.interword_silence =
> >  > (procedural.Silence(self.inter_word_time))
>
> >  >     def lookup_ch(self, ch):
> >  >         res = self._code.get(ch.upper(), '')
> >  >         if not res:
> >  >             print "error no such char for %s" % ch
> >  >         return res
>
> >  >     def _add_to_sound(self, sound, dots_dashes):
> >  >         lst = list(dots_dashes)
> >  >         lst = 'x'.join(lst)
> >  >         print lst
> >  >         for dot_dash in lst:
> >  >             if dot_dash == '.':
> >  >                 sound.add_sound(self.ditsound)
> >  >             if dot_dash == '-':
> >  >                 sound.add_sound(self.dahsound)
> >  >             if dot_dash == 'x':
> >  >                 sound.add_sound(self.intrachar_silence)
>
> >  >     def get_sound(self):
> >  >         res = ProceduralSoundSequence()
> >  >         words = self.msg.split(' ')
> >  >         for word in words:
> >  >             for ch in word:
> >  >                 dots_dashes = self.lookup_ch(ch)
> >  >                 self._add_to_sound(res, dots_dashes)
> >  >         return media.StaticSource(res)
>
> >  > class ProceduralSoundSequence(procedural.ProceduralSource):
> >  >     def __init__(self, frequency=440, **kwargs):
> >  >         super(ProceduralSoundSequence, self).__init__(0, **kwargs)
> >  >         self.frequency = frequency
> >  >         self.data = ""
> >  >         self._duration = 0
>
> >  >     def add_sound(self, sound):
> >  >         data = sound._generate_data(sound._max_offset - sound._offset,
> >  > 0)
> >  >         if not isinstance(data, str):
> >  >             data = cast(data, POINTER(c_char))
> >  > [:len(data)*sizeof(c_short)]
> >  >         self.data += data # Sine returns a c_char array but Silence
> >  > returns a string
> >  >         self._duration += sound._duration
> >  >         self._max_offset += sound._max_offset
>
> >  >     def _generate_data(self, bytes, offset):
> >  >         offset = offset - (offset % 2)
> >  >         res = self.data[offset:bytes+offset]
> >  >         return res
>
> >  > def testcw():
> >  >     # The OpenGL context is created only when you create a window.
> >  > Any calls
> >  >     # to OpenGL before a window is created will fail.
>
> >  >     win = window.Window(visible=False)
> >  >     win.set_visible()
>
> >  >     # ... perform any OpenGL state initialisation here.
> >  >     glShadeModel(GL_SMOOTH)
> >  >     glClearColor(0, 0, 0, 0.5)
> >  >     glClearDepth(1.0)
> >  >     glEnable(GL_DEPTH_TEST)
> >  >     glDepthFunc(GL_LEQUAL)
> >  >     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
>
> >  >     glLoadIdentity()
>
> >  >     player = media.Player()
>
> >  >     player.eos_action = player.EOS_NEXT
>
> >  >     win.push_handlers(event.WindowEventLogger())
> >  >     win.clear()
>
> >  >     #game = cw_game(win, player)
>
> >  >     sin = procedural.Sine(0.1)
> >  >     a = cw_sound('T').get_sound()
> >  >     b = cw_sound('T').get_sound()
> >  >     player.queue(sin)
> >  >     player.queue(a)
> >  >     player.queue(b)
> >  >     player.queue(sin) #<-- this one doesn't play
> >  >     player.queue(sin)
> >  >     while not win.has_exit:
> >  >         time_passed = clock.tick()
> >  >         player.play()
> >  >         win.flip()
> >  >         win.dispatch_events()
> >  >         player.dispatch_events()
>
> >  > if __name__ == '__main__':
> >  >     testcw()
>
> It's helpful if you can provide a more minimal test case that still
> fails.  Also let us know what platform you're on and which audio
> driver you're using (see documentation for pyglet.options['audio']).
>
> Alex.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to