On 16/11/11 22:50, makemachine wrote:
> This sounds like a simpler approach. Is there somewhere that I can see
> an example of what you mean by using a modified source?
> 
> Thanks, 
> ~J

Well the simplest way, as I mentioned before, is just to create a
StaticSource and change the _data attribute ie:

music = pyglet.media.load("/some/file.ogg", streaming=False)
music._data = data_string # data_string is your new audio data

If you want to modify a streamed source on the fly then load your file
and pass it to a new Source class ie:

music = pyglet.media.load("/some/file.ogg")

class MySource(pyglet.media.Source):
    def __init__(self, music):
        self.music = music
    def get_audio_data(self, bytes):
        data = self.music.get_audio_data(bytes)
        # Do your filtering here
        return pyglet.media.AudioData(data, duration...)

As you can see you just need to reimplement get_audio_data really. If
you just want to make your own sounds on the fly just skip the bit about
passing in some music file and reimplement get_audio_data so that it
passes out your sinusoid or whatever wave you like.

HTH,

Adam.

-- 
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