Code is here:
http://code.google.com/p/poise-sfx/
Check out PygletSource.py and test-pyglet.py for the general approach.
Regards
Crispin
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pyglet-users/-/-yP1ovxcgfAJ.
> To post to this group, send email to pyglet...@googlegroups.com.
> To unsubscribe from this group, send email to
> pyglet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.
>
I'm just using numpy with a modified Source so I can change the sound on
the fly. If you just wanted plain waves you could produce the arrays and
set the StaticSource()._data manually.
HTH,
Adam.
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.
Actually the very first cut was generators that yielded sample values.
But the call overhead was just so great there was no way you could
generate 44100 meaningful values in a second.
Crispin
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pyglet-users/-/OldRC8WaL0gJ.