I'm still not sure on the best way to implement it under the hood. In order to properly calculate the envelopes, they need to know the duration and framerate so you do the math right. In my test implementation, the envelopes are just generators. You make an instance of it, but they don't work yet. This is because the top of the generator has: framerate, length = yield This means you must pass these values in before they work. The sound souce (Sine wave in the above example) will prime the envelope with it's own framerate/length, and can then use it. This will all probably work out, but it s a little bit funky.
It would be a whole lot easier if the envelopes were just methods on the ProceduralSound base class. The only issue with doing it this way, is that I can't think of a clean API with which to create and use the envelopes. Maybe the envelopes could be very simple classes (or named tuples) that contain the envelope parameters only... You then pass it in, and the procedural source does that actual generation of the envelope from it's own private methods. I think I'll try that and see how it looks. This way might be better as well, because you could then add an envelope atribute to the waveform and do something like: adsr_envelope = procedural.ADSREnvelope(attack=0.05, decay=0.1, sustain_amplitude=0.7, release=0.3) sine_wave = procedural.Sine(duration=1, frequency=220, envelope= adsr_envelope) sine_wave.play() sine_wave.seek(0) sine_wave.envelope = new_envelope sine_wave.play() On Sunday, December 11, 2016 at 8:54:56 AM UTC+9, [email protected] wrote: > > That seems fine, it actually looks a bit more straight forward than > binding OpenAL effects to sound samples. > > I'm going to assume we can modify envelope parameters and swap envelopes > after its bound to a waveform? > > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
