|
From: Andrew C <cou...@gm...> - 2021-04-04 20:24:41
|
Hi all, I'm looking into creating a poorman's round robin script for some short note staccatos. My plan is to write a script which will: At note on, pick a random number between 0 and 4. Play either the same note, 2 semitones up but repitched to the original note's pitch, 1 semitone up but repitched, 2 semitones down but repitched or 1 semitone down but repitched. I looked at the NKSP reference manual and it seems like I can achieve the first part with the Random() function. I'm considering using change_pitch function to simply tell the future note to pitch itself up or down and then use play_note to play the new note's sample but repitched. play_note does send a new midi note_on event, if I'm not mistaken? Thanks, Andrew. |
|
From: Christian S. <sch...@li...> - 2021-04-06 09:21:23
|
On Sonntag, 4. April 2021 22:24:09 CEST Andrew C wrote: > Hi all, > > I'm looking into creating a poorman's round robin script for some short > note staccatos. I assume you want to use sfz. In this case create a text file somewhere which you will fill with NKSP script code and link that script in your sfz file with the 'script' opcode: http://doc.linuxsampler.org/sfz/script_opcode/ The advantage with the gig format is that you get immediate syntax / error / warning feedbacks while typing the script in gigedit's script editor. So this is probably more convenient and faster, especially on first steps. However alternatively you can also use 'ls_instr_script' from the command line to check your script for errors: cat /some/where/foo.txt | ls_instr_script sfz Additional options are described by: ls_instr_script > My plan is to write a script which will: > > At note on, pick a random number between 0 and 4. on init declare polyphonic $n end init on note $n := random(0, 4) message("Random number is " & $n) ... end on > Play either the same note, 2 semitones up but repitched to the original > note's pitch, 1 semitone up but repitched, 2 semitones down but repitched > or 1 semitone down but repitched. select $n case 0 play_note($EVENT_NOTE + 2, $EVENT_VELOCITY) case 1 ... case 2 ... case 3 ... case 4 ... end select I don't get though what you mean with "repitched to the original note's pitch". Do you want to start it with a x semitones offset and let it slide to the original pitch within a certain duration? > I looked at the NKSP reference manual and it seems like I can achieve the > first part with the Random() function. > > I'm considering using change_pitch function to simply tell the future note > to pitch itself up or down and then use play_note to play the new note's > sample but repitched. The function is called change_tune() for some reason (KSP invention): http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/ change_tune_function/ And you would probably want to use it in conjunction with change_tune_time() to control how long it will take to perform the tuning/pitch change. > > play_note does send a new midi note_on event, if I'm not mistaken? Yes. This tour is probabably a good starting point: http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/ Hover your mouse over keywords to see a short summary what they are doing. Click on them to get to the detailed description of the keyword. > > Thanks, > > Andrew. CU Christian |
|
From: Andrew C <cou...@gm...> - 2021-04-06 09:40:21
|
Hi Christian, Thanks so much for the code snippets, they'll get me off to a good start! I'll be doing this wholly in gig format, not sfz. What I mean by repitching the note is not a slide, but rather play for example "$EVENT_NOTE +1" (A C# sample) at the same pitch as C ($EVENT_NOTE).. That way if I have a semitone sampled instrument, I could effectively get extra repitched samples per note. I think for this I can simply use change_tune to do an "instant" -100 cent tune down so the C# sample sounds at the C pitch without too much stretching? Cheers. Andrew. On Tue, Apr 6, 2021 at 10:21 AM Christian Schoenebeck < sch...@li...> wrote: > On Sonntag, 4. April 2021 22:24:09 CEST Andrew C wrote: > > Hi all, > > > > I'm looking into creating a poorman's round robin script for some short > > note staccatos. > > I assume you want to use sfz. In this case create a text file somewhere > which > you will fill with NKSP script code and link that script in your sfz file > with > the 'script' opcode: > > http://doc.linuxsampler.org/sfz/script_opcode/ > > The advantage with the gig format is that you get immediate syntax / error > / > warning feedbacks while typing the script in gigedit's script editor. So > this > is probably more convenient and faster, especially on first steps. > > However alternatively you can also use 'ls_instr_script' from the command > line > to check your script for errors: > > cat /some/where/foo.txt | ls_instr_script sfz > > Additional options are described by: > > ls_instr_script > > > My plan is to write a script which will: > > > > At note on, pick a random number between 0 and 4. > > on init > declare polyphonic $n > end init > > on note > $n := random(0, 4) > message("Random number is " & $n) > ... > end on > > > Play either the same note, 2 semitones up but repitched to the original > > note's pitch, 1 semitone up but repitched, 2 semitones down but repitched > > or 1 semitone down but repitched. > > select $n > case 0 > play_note($EVENT_NOTE + 2, $EVENT_VELOCITY) > case 1 > ... > case 2 > ... > case 3 > ... > case 4 > ... > end select > > I don't get though what you mean with "repitched to the original note's > pitch". Do you want to start it with a x semitones offset and let it slide > to > the original pitch within a certain duration? > > > I looked at the NKSP reference manual and it seems like I can achieve the > > first part with the Random() function. > > > > I'm considering using change_pitch function to simply tell the future > note > > to pitch itself up or down and then use play_note to play the new note's > > sample but repitched. > > The function is called change_tune() for some reason (KSP invention): > > http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/ > change_tune_function/ > <http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/change_tune_function/> > > And you would probably want to use it in conjunction with > change_tune_time() > to control how long it will take to perform the tuning/pitch change. > > > > > play_note does send a new midi note_on event, if I'm not mistaken? > > Yes. > > This tour is probabably a good starting point: > > http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/ > > Hover your mouse over keywords to see a short summary what they are doing. > Click on them to get to the detailed description of the keyword. > > > > > Thanks, > > > > Andrew. > > CU > Christian > > > > > _______________________________________________ > Linuxsampler-devel mailing list > Lin...@li... > https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel > |
|
From: Christian S. <sch...@li...> - 2021-04-06 10:08:35
|
On Dienstag, 6. April 2021 10:39:55 CEST Andrew C wrote:
> Hi Christian,
>
> Thanks so much for the code snippets, they'll get me off to a good start!
> I'll be doing this wholly in gig format, not sfz.
Ok, then just hit Ctrl + S whenever you changed something in gigedit's script
editor. That will cause the script to be reloaded by the sampler to make your
changes audible.
> What I mean by repitching the note is not a slide, but rather play for
> example "$EVENT_NOTE +1" (A C# sample) at the same pitch as C
> ($EVENT_NOTE)..
> That way if I have a semitone sampled instrument, I could effectively get
> extra repitched samples per note.
>
> I think for this I can simply use change_tune to do an "instant" -100 cent
> tune down so the C# sample sounds at the C pitch without too much
> stretching?
The trick here is that play_note() returns the note ID of that
programmatically triggered new note. So you would use that note id and pass it
to change_tune() like:
on init
declare polyphonic $staccatoNote
end init
on note
...
$staccatoNote := play_note($EVENT_NOTE + $n, $EVENT_VELOCITY)
{ let's say drop pitch by 30 cents immediately }
change_tune($staccatoNote, -30c)
end note
Because obviously you just want to change the tuning of that sample; not of
the original one. If you want to change the original one as well, let's say
bring some randomness there as well:
change_tune($EVENT_NOTE, random(-30C, +30C))
I guess you get the point.
CU
Christian
|
|
From: Andrew C <cou...@gm...> - 2021-04-07 14:31:46
|
Hi Christian/List, I've written and fully tested a working "neighbour notes" round robin script with some rudimentary logic to avoid "dead" notes at either extreme of the instrument. The initial instrument range is for a cello, but can easily be edited for any instrument range. I've uploaded it here (RRCello. LScript): https://drive.google.com/file/d/18c6iL-zR-tDYNBFyqUS01HnZipwbvPuJ/view?usp=sharing If nothing else, it might serve as a good "real world" example of NKSP in Linuxsampler. Cheers, Andrew. On Tue, Apr 6, 2021 at 11:10 AM Christian Schoenebeck < sch...@li...> wrote: > On Dienstag, 6. April 2021 10:39:55 CEST Andrew C wrote: > > Hi Christian, > > > > Thanks so much for the code snippets, they'll get me off to a good start! > > I'll be doing this wholly in gig format, not sfz. > > Ok, then just hit Ctrl + S whenever you changed something in gigedit's > script > editor. That will cause the script to be reloaded by the sampler to make > your > changes audible. > > > What I mean by repitching the note is not a slide, but rather play for > > example "$EVENT_NOTE +1" (A C# sample) at the same pitch as C > > ($EVENT_NOTE).. > > That way if I have a semitone sampled instrument, I could effectively get > > extra repitched samples per note. > > > > I think for this I can simply use change_tune to do an "instant" -100 > cent > > tune down so the C# sample sounds at the C pitch without too much > > stretching? > > The trick here is that play_note() returns the note ID of that > programmatically triggered new note. So you would use that note id and > pass it > to change_tune() like: > > on init > declare polyphonic $staccatoNote > end init > > on note > ... > $staccatoNote := play_note($EVENT_NOTE + $n, $EVENT_VELOCITY) > { let's say drop pitch by 30 cents immediately } > change_tune($staccatoNote, -30c) > end note > > Because obviously you just want to change the tuning of that sample; not > of > the original one. If you want to change the original one as well, let's > say > bring some randomness there as well: > > change_tune($EVENT_NOTE, random(-30C, +30C)) > > I guess you get the point. > > CU > Christian > > > > > _______________________________________________ > Linuxsampler-devel mailing list > Lin...@li... > https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel > |
|
From: Christian S. <sch...@li...> - 2021-04-08 18:24:45
|
On Mittwoch, 7. April 2021 16:31:10 CEST you wrote: > Hi Christian/List, > > I've written and fully tested a working "neighbour notes" round robin > script with some rudimentary logic to avoid "dead" notes at either extreme > of the instrument. > The initial instrument range is for a cello, but can easily be edited for > any instrument range. > > I've uploaded it here (RRCello. LScript): > https://drive.google.com/file/d/18c6iL-zR-tDYNBFyqUS01HnZipwbvPuJ/view?usp=s > haring > > If nothing else, it might serve as a good "real world" example of NKSP in > Linuxsampler. Just some notes/tips from my side: > on init > {Round robin script for Cello. Version 0.1} > {Written by Andrew Coughlan. Released under GPL v2 or later.} Maybe a more detailed description what the script does would make sense. E.g. "Assumes an instrument with one sample per key; it emulates round robin samples by randomly picking another sample (from another region) and pitching it up or down accordingly." > > declare polyphonic $n > declare polyphonic $RR > declare polyphonic $lokey := 36 {lowest playable note of this instrument} > declare polyphonic $hikey := 76 {highest playable note of this instrument} > > end on You could automate retrieval of $lokey and $hikey, at least for gig sounds: by calling same_region($i, $i) in a loop inside on init .. end on for all 127 possible MIDI note numbers can could check which region does have a sample mapped to a MIDI key: http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/same_region_function/ And no need to make $lokey and $hikey polyphonic, as their values don't ever change during individual note events. > on note > {message ("Note played is number: " & $EVENT_NOTE)} > {uncomment for getting lokey/hikey instrument range numbers} > > ignore_event() > > if ( $EVENT_NOTE +2 > $hikey .and. $EVENT_NOTE <= $hikey ) ".and." is a bitwise and, which is quite special. In this case you would just use the regular logical-and without the dots ("and"). Not that it would make much of a difference in this case though. > > $n := random(0, 2) > > select $n > > case 0 > > $RR := play_note($EVENT_NOTE -2, $EVENT_VELOCITY) > change_tune($RR, 200c) > > case 1 > > $RR := play_note($EVENT_NOTE -1, $EVENT_VELOCITY) > change_tune($RR, 100c) > > case 2 > > $RR := play_note($EVENT_NOTE, $EVENT_VELOCITY) > > end select As $n is used nowhere else, you could also just inline the random() call like: select random(0, 2) ... end select If you want a true round robin behaviour, not a randomized one, then you would probably use a global variable instead and increment it with each note: on init { important: not polyphonic! } declare $rr end on function bumpRoundRobin synchronized $rr := $rr + 1 if ($rr > 2) $rr := -2 end if end synchronized end function on note call bumpRoundRobin() select $rr ... end select end on > > else > > if ( $EVENT_NOTE -2 < $lokey .and. $EVENT_NOTE >= $lokey ) > > $n := random(0, 2) > > select $n > > case 0 > > $RR := play_note($EVENT_NOTE +2, $EVENT_VELOCITY) > change_tune($RR, -200c) > > case 1 > > $RR := play_note($EVENT_NOTE +1, $EVENT_VELOCITY) > change_tune($RR, -100c) > > case 2 > > $RR := play_note($EVENT_NOTE, $EVENT_VELOCITY) > > end select > > else > > if ($EVENT_NOTE -1 > $lokey .and. $EVENT_NOTE +2 < $hikey) > > $n := random(0, 4) > > select $n > > case 0 > > $RR := play_note($EVENT_NOTE -2, $EVENT_VELOCITY) > change_tune($RR, 200c) > > case 1 > > $RR := play_note($EVENT_NOTE -1, $EVENT_VELOCITY) > change_tune($RR, 100c) > > case 2 > > $RR := play_note($EVENT_NOTE +2, $EVENT_VELOCITY) > change_tune($RR, -200c) > > case 3 > > $RR := play_note($EVENT_NOTE +1, $EVENT_VELOCITY) > change_tune($RR, -100c) > > case 4 > > $RR := play_note($EVENT_NOTE, $EVENT_VELOCITY) > > end select > end if > > end if > > end if > > > end on Alternatively you could also reduce the overall amount of code lines tremendously by dropping the select ... end select approach and using arithmetics instead: $n := random(-2, +2) $RR := play_note($EVENT_NOTE + $n, $EVENT_VELOCITY) if ($n) change_tune($RR, $n * -100c) end if CU Christian |