Yes! That made it work, scale name is appended .
Awesome
Thanks for helping, we got there in the end!
Try to use os.platform() to get the current OS name. You can adapt the slash according to what you find.
The easiest thing is :
$PATH_SLASH = “/”
if os.platform() == “WINDOWS” then
$PATH_SLASH = “\”
end
$filepath = $root_path…$PATH_SLASH…$chosen_file_path…$PATH_SLASH…$filename
There are a couple of existing tools using the os.platform() for these cases, so plenty of examples to browse through their solutions.
Thanks, I’ll try that… would that be a better way to do it than just using string.gsub to swap the \ with / ?
Which tools are those?
It was indeed a bug in my script. I simply overlooked the fact that a line in the .scl may contain extra stuff like “cents” or “C#”, etc., so the tunings were not being parsed correctly from lines such as “230.440 cents”. I’ve fixed this now by making the line parsing a bit more robust. You can find the updated script in the original thread: Snippet: Load Scala .Scl Tuning File
Awesome, thanks! I’ve added it to the tool and updated the OP.
It works great
Hi this is pretty cool! I have only one update suggestion: maybe the script could take into account, the base_note property of the original instrument/samplemapping, if it’s in a reasonable (say ± 48 or something) range from C-4. It will come in handy if you ever want to use a sample that’s not on C-4.
Good idea, I initially thought that this would need a GUI but I can just read the existing base note of the instrument so it should much simpler to implement. Thanks, I’ll put it in the next update.
awesome
exactly, just compare the .base_note with 48 and add that to every .transpose value
btw you should email the foundation / page of scala, to add Renoise to the list of supported export systems
EDIT: Yes you are right, I was over complicating it! I will also need to store the base note value somewhere as Renoise discards this when a sample is sliced. Being able to traspose the scale would also be a useful feature to have although I’m not sure how you could do this without building a GUI.
Good idea, i’ll do that
But it’s not complicated at all… Say you have a sample that instead of C-4, was recorded on A-3. That’s exactly 3 semitones below “normal” playback… so to be able to play pc keyboard / midi keyboard and hear the notes that you press, normally you would just set the base_note to A-3 by right-clicking on that key in the Sample Keyzones window. You can verify by experiment easily with any sample that transposing a sample up by 3 semitones (i.e. via normal transpose slider) has exactly the same effect as setting this root note of the sample to A-3. Another tool called Scale Mapper actually makes use of this possibility by adding layers (pointing to the same sample) that have a different root note.
So to add support for different root notes to your tool, all you would have to do, is calculate the difference in the function apply_tunings:
local base_note = 48
local offset = base_note - renoise.song().selected_instrument:sample_mapping(1,1).base_note
and about 20 lines later, where there’s now this:
transpose[n], finetune[n] = math.modf(12*(math.log10((frequencies[n]/base_frequency))/math.log10(2)))
you could add:
transpose[n], finetune[n] = math.modf(12*(math.log10((frequencies[n]/base_frequency))/math.log10(2)))
transpose[n] = transpose[n] + offset -- correction for samples on another root note
So basically you only have to add two lines of code, the second line of this last block and the second line of the first. Of course you don’t have to detect root note and stuff… Just expect people to set root note of samples for themselves first, then apply the tool. You could even think of allowing the original un-retuned sample to have a transpose/finetune value other than 0, and calculate that in, carrying a txpose_offset and ftune_offset into the equation. But I wouldn’t mind if you don’t, it’s probably rubbish.
I ask this because my tool Overtune renders everything on A-0, for crispness. It’s not always handy, for this tool to be handy I’ll render to C-4, but maybe A-2 or A-3 might suffice if this update is added. (Overtune does count on A-4 always being 440Hz btw, although I have an old music book here where it’s defined as a 435Hz tone.)
I think my “InstrMixer” tool has a shortcut for that, but I’ll check.
edit: I had a bug in first block!
PS. I think one more thing could be added, although I’m not sure myself how well this works:
renoise.song():describe_undo(description)
just before you access a renoise.song() object. I have experience with it taking then after it a whole bunch of things as one undo action though. When I insert FX with shortcuts it has a custom undo description and then if I change the parameters 20 times, still one Ctrl+Z will remove the whole device, so be careful.
So, yes, the InstrMix tool does provide a way of transposing every mapping one down, one up, and octave down/up. Like this:
Launch InstrMix with key (I use Shift+G)
Press Z to toggle ‘apply to all mode’ on
Press K/L to transpose down/up (takes a while when applying to 120 layers!), or Shift+K/L for octave
Press Z again in the end to toggle ‘all mode’ off again
But in general if you’ve already composed it’s faster to just use Renoises Shift+F1/F2/F11/F12 on the tracks.
Yes, you are quite right, you posted as I was editing my initial response to you. I had a brain freeze and was getting it confused with transposing the scale
Thanks for the code examples…
Nice, I didn’t realise you could get the base note this way, I was using:
renoise.song().instruments[ins].sample_mappings[renoise.Instrument.LAYER_NOTE_ON][1].base_note
And it took me a while to figure that out! Your way of doing it seems much more elegant. I still haven’t fully got my head around the differences between using ‘:’ and ‘.’ or when to use ( ) instead of
Honestly I don’t really consider myself a programmer, more of a trial and errorist! My tools are generally cobbled together after lots head scratching, trial and error, and looking at other code
lol, yes I know, I wrote that it was my first ever tool, the codes a mess though. I can’t really remember how I made that work
Anyway, thanks for the advice…
Ah yes, that’s cool but different to what I was thinking about. What I mean is transposing the entire scale and the individual note ratios and this would require the fine tuning settings to be shifted up and down.
So for example say C is tranposed at 0, and D is transposed at 2 with finetuning of 33 - Transposing the scale to A would mean that A would be transposed at 0 and B would be transposed at 2 with finetuning of 33. So I would have to adapt your code to shift the finetunings up and down the keyboard as well.
I like the idea of using keyboard shortcuts to do it though
Thanks, I didn’t know about that, I’m using the process slicer which means each slice created is an undo action. Being able to undo the whole operations would be very useful!
Don’t forget the boundary sanity checks (max/min transpose levels etc.)
Thanks, I have a clamping function that sorts that out.
Updated to 1.5 - Now preserves the base note setting of the initial sample, this also works on repeated re-tunings as the base note is stored in the beat sync setting.
Also added the ability to preserve/apply the loop start and end points of the initial sample to all slices, however due to API limitations this needs to be applied manually after the ‘stop playing at start of next slice’ option has been disabled in the Sample Editor. Once the loop setting has been applied it doesn’t need to be done again for further retunings.
Awesome
IIRC this already worked, without any work or extra code
it’s a shame the “Toggle Single Slice Trigger” bool is not accessible through the API… would make the process a hell of a lot more streamlined
Nope, try it yourself run this code on a looped sample:
for n = 1, 10, 1 do
renoise.song().instruments[1].samples[1]:insert_slice_marker(1)
end
The slices lose the loop points so you then have to set them again, however running this code straight after:
for n = 1, 10, 1 do
renoise.song().instruments[1].samples[n].loop_start = 1
renoise.song().instruments[1].samples[n].loop_end = 5000
end
Doesn’t work either until you have manually disabled the “stop at slice end” setting in the sample editor. You can’t access that via scripting…