Set volume for message

  • Is there an equivalent function to Message.setFineDetune(); but for volume/gain rather than pitch? I'm thinking that I want to fade a note in from silence so I'll need to silence it first.

  • Yes, Message.setGain(volume) (it was missing in the API list, but it's there). volume is the decibel value, and -100 means silence.

  • Brilliant, thanks!

  • I'm assuming these won't work with script generated notes... is there a way to do the same thing using event IDs?

  • You'll get the new event ID of the artificial note as return value of the Synth.playNote() function and can use this to make a zero time fade:

    local i = Synth.playNote(Message.getNoteNumber(), Message.getVelocity());
    Synth.addVolumeFade(i, 0, -12);

    However, the second line doesn't work yet because you'll need to apply a positive time. I'll fix this.

  • Yes I tried this with the pitchFade but it didn't work, I assumed it was because only the last fade command in the on note callback had any effect, now I know the reason 🙂

  • I fixed this now, so that these two lines are equivalent:

    Synth.addVolumeFade(Message.getEventId(), 0, -12);

    But you can use the latter method to use other event IDs than the one from the callback (including artificial events). However, the first line is a bit faster, because you don't have to add another event so if possible I'd prefer this one. The corresponding pitch methods are fixed the same way of course.

    And its true that only the last fade command is used (with the new exception when the fade time is zero) so you can't implement zig zag curves like this:

    Synth.addPitchFade(id, 500, -12, 0); // this will be ignored
    Synth.addPitchFade(id, 1000, 0, 0);
    Synth.addPitchFade(id, 0, -12, 0); // this will be OK
    Synth.addPitchFade(id, 1000, 0, 0);
    // ...

    The command just tells the synth to ramp to the given value but the target value (and time if non zero) will be overwritten.

  • Brilliant, thanks 🙂 this will be very helpful

  • This is also what I want to set in terms of the device's message ringtone. They are great, aren't they?

  • @Alethea21 said in Set volume for message:

    This is also what I want to set in terms of the device's message ringtone. They are great, aren't they? will be what i would recommend for you

Log in to reply