Set rate of SamplePlayer with envelope

16 views
Skip to first unread message

sc3...@gmail.com

unread,
Feb 19, 2021, 9:58:01 AM2/19/21
to beadsproject
Hi,

I want to set the rate of SamplePlayer with an envelope
and I want that envelope to be retriggered when it is finished.

Is this the correct way ?

private void setRateEnvelope() {
float currentRate = this.samplePlayer.getRate();
Envelope envelope = new Envelope(this.audioContext);
envelope.addSegment(currentRate, 100f);
envelope.addSegment(0.2f, 8000f);
envelope.addSegment(2.2f, 10000f);
envelope.addSegment(currentRate, 8000f, new Bead() {
@Override
public void messageReceived(Bead b) {
setRateEnvelope();
}
});
this.samplePlayer.setRate(envelope);
}

Thanks
Regards

Ollie Bown

unread,
Feb 21, 2021, 5:28:53 PM2/21/21
to beadsp...@googlegroups.com
Generally that’s not a common way to do things (well OK maybe in JavaScript aync programming) as you don’t give yourself a way to exit the loop, but it works and you can still kill the signal chain, breaking the loop. Envelopes are not loopable. Two alternatives: (1) create a WavePlayer and populate a buffer with the envelope signal data. (2) use a clock to trigger this Envelope sequence (make sure you call “clear()” on the Envelope before restarting it, to ensure nothing gets backed up).

Ollie

--
You received this message because you are subscribed to the Google Groups "beadsproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beadsproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beadsproject/60b087b7-9080-4beb-b22e-7471c8d3ef1en%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages