Author Topic: BASS_Mixer_StreamAddChannelEx() and BASS_Mixer_ChannelSetEnvelope()  (Read 262 times)

3delite

  • Posts: 904
Hi!

Is the following officially implemented, will the envelope start after the delay specified for BASS_Mixer_StreamAddChannelEx()?

Code: [Select]
    BASS_ChannelLock(Channel, True);
    try
        if (Source is TAudioItemSample)
        AND ((Source as TAudioItemSample).Delay > 0)
        then begin
            BASS_Mixer_StreamAddChannelEx(Channel, TAudioItemSample(Source).Channel, BASS_STREAM_AUTOFREE, BASS_ChannelSeconds2Bytes(Channel, (Source as TAudioItemSample).Delay), 0);
        end else begin
            BASS_Mixer_StreamAddChannel(Channel, TAudioItemSample(Source).Channel, BASS_STREAM_AUTOFREE);
        end;
        //* Attack
        Nodes[0].pos := 0;
        Nodes[0].value := 0;
        Nodes[1].pos := BASS_ChannelSeconds2Bytes(TAudioItemSample(Source).Channel, TAudioItemSample(Source).Attack);
        Nodes[1].value := TAudioItemSample(Source).Power;
        BASS_Mixer_ChannelSetEnvelope(TAudioItemSample(Source).Channel, BASS_MIXER_ENV_VOL, @Nodes, 2);
        TAudioItemSample(Source).SyncDecay := BASS_Mixer_ChannelSetSync(TAudioItemSample(Source).Channel, BASS_SYNC_MIXTIME OR BASS_SYNC_MIXER_ENVELOPE, BASS_MIXER_ENV_VOL, @CallbackDecay, Source);
    finally
        BASS_ChannelLock(Channel, False);
    end;

Thank you!

Ian @ un4seen

  • Administrator
  • Posts: 20426
Yes, that will work fine. A source's envelopes are only processed when the source is processed, so delaying/pausing a source also delays/pauses its envelopes.

3delite

  • Posts: 904
That's great, thank you very much! :)