Found something. If you mark the region, then unmark it and save a new preset, the regionStart
is not updated correctly in the new preset
Does selecting a range in soundfiler produce a output?
Thatās the position in samples of the place you last clicked. I can have it revert to 0 but thatās even more of a lie. I guess setting it to -1 would be best?
[edit] setting it to -1 makes a mess of the entire thing, I think Iāll leave it. regionStart
means nothing unless regionLength
is greater than 0. If you keep that in mind I donāt see any issues, or am I missing something?
Youāre right, seems to save and load presets correctly the way it is now.
ā¦but something else I also noticed:
If you close Reaper, and reopen the project, the audio-file will not play until you re-load it into the sampler.
I think itās just down to how you code it. This example works fine for me:
<Cabbage>
form caption("Stretch") size(600, 500), guiMode("queue"), pluginId("1287"), colour (0,100,0)
keyboard bounds(102, 380, 381, 95)
rslider bounds(378, 302, 60, 60) channel("Speed") range(0.001, 1, 1, 1, 0.001)
soundfiler bounds(110, 52, 300, 200), channel("Soundfiler1", "Soundfiler2"), colour(188, 188, 188), tableBackgroundColour(62, 71, 86), showScrubber(1), displayType("mono")
presetbutton bounds(24, 14, 120, 23), channel("PresetChannel"), colour:0(16, 19, 22, 255), fontColour(176, 176, 176), textColour(176, 176, 176), presetNameAsText(1), factoryFolder("#USER_APPLICATION_DATA_DIRECTORY/CabbageTest/Soundfiler/Presets/Factory", "*.psts"), userFolder("#USER_APPLICATION_DATA_DIRECTORY/CabbageTest/Soundfiler/Presets/User", "*.psts"), highlightedItemColour(200, 200, 200) highlightedTextColour(25, 25, 25), outlineColour(44, 47, 49), outlineThickness(1), corners(2)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
instr 98
gSfile cabbageGet "LAST_FILE_DROPPED"
if (changed(gSfile) == 1) then
cabbageSet 1, "Soundfiler1", "file", gSfile
endif
endin
instr 1
Sfile cabbageGet "Soundfiler1", "file"
if filevalid(Sfile) == 1 then
if filenchnls(Sfile) == 1 then
a1 diskin2 Sfile, 1, 0, 1
outs a1, a1
else
a1, a2 diskin2 Sfile, 1, 0, 1
outs a1, a2
endif
endif
endin
</CsInstruments>
<CsScore>
f0 z
i98 0 z
</CsScore>
</CsoundSynthesizer>
Seems like you got me again, this example works fine
I think thereās a bug when getting the RegionStart, like I wrote here:
The issue is that the RegionStart is not correctly initialized to 0 after releasing the region. The RegionLength however works correct. If you use this in setting the starting position when reading a file, it will read from another point than what the soundfiler is visually displaying.
Edit: I also suspect the region-length is a wrong amount of samples? But not sure. Check the example below
<Cabbage>
form caption("Stretch") size(600, 500), guiMode("queue"), pluginId("1287"), colour (0,100,0)
keyboard bounds(102, 380, 381, 95)
rslider bounds(378, 302, 60, 60) channel("Speed") range(0.001, 1, 1, 1, 0.001)
soundfiler bounds(110, 52, 300, 200), channel("Soundfiler1", "Soundfiler2"), colour(188, 188, 188), tableBackgroundColour(62, 71, 86), showScrubber(1), displayType("mono")
presetbutton bounds(24, 14, 120, 23), channel("PresetChannel"), colour:0(16, 19, 22, 255), fontColour(176, 176, 176), textColour(176, 176, 176), presetNameAsText(1), factoryFolder("#USER_APPLICATION_DATA_DIRECTORY/CabbageTest/Soundfiler/Presets/Factory", "*.psts"), userFolder("#USER_APPLICATION_DATA_DIRECTORY/CabbageTest/Soundfiler/Presets/User", "*.psts"), highlightedItemColour(200, 200, 200) highlightedTextColour(25, 25, 25), outlineColour(44, 47, 49), outlineThickness(1), corners(2)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
instr 98
gSfile cabbageGet "LAST_FILE_DROPPED"
if (changed(gSfile) == 1) then
cabbageSet 1, "Soundfiler1", "file", gSfile
endif
endin
instr 1
Sfile cabbageGet "Soundfiler1", "file"
iRegionStart cabbageGetValue "Soundfiler1"
iRegionLength cabbageGetValue "Soundfiler2"
iFileSr filesr gSfile
iSampleLengthSeconds filelen gSfile
iRegionLengthSeconds divz iRegionLength, iFileSr, 44100
printk 0.1, iSampleLengthSeconds
printk 0.1, iRegionLengthSeconds
if filevalid(Sfile) == 1 then
if filenchnls(Sfile) == 1 then
a1 diskin2 Sfile, 1, 0, 1
outs a1, a1
else
a1, a2 diskin2 Sfile, 1, 0, 1
outs a1, a2
endif
endif
endin
</CsInstruments>
<CsScore>
f0 z
i98 0 z
</CsScore>
</CsoundSynthesizer>
Seems fine in my tests here. I have a four second clips, when I select half the instrument returns 2, a quarter, 1, etc.
Iām not sure why you would use regionStart
to set the starting position of playback, if there is no region set. Check regionLength
, if itās 0 use scrubberPosition
to set playback back to the start of the file. That should do the trick.
My logic was that since both regionStart
and regionLength
initializes to 0 when compiling, and the regionLength
sets automatically to 0 when releasing the region, the regionStart
would also set to 0 when releasing the region
Thanks, that seems like a good solution
Okay thanks, going to test this further then, must be my implementation.
It seems like thereās a issue with the soundfiler, and I think it has to do with sample rate. Tested it on 3 different files with different sample rates, happened on all of them. Check out the example, this demonstrates the wrongly read region length.
I am on 48k sr.
<Cabbage>
form caption("Stretch") size(600, 500), guiMode("queue"), pluginId("1287"), colour (0,100,0)
keyboard bounds(102, 380, 381, 95)
rslider bounds(378, 302, 60, 60) channel("Speed") range(0.001, 1, 1, 1, 0.001)
soundfiler bounds(110, 52, 300, 200), channel("Soundfiler1", "Soundfiler2"), colour(188, 188, 188), tableBackgroundColour(62, 71, 86), showScrubber(1), displayType("mono")
presetbutton bounds(24, 14, 120, 23), channel("PresetChannel"), colour:0(16, 19, 22, 255), fontColour(176, 176, 176), textColour(176, 176, 176), presetNameAsText(1), factoryFolder("#USER_APPLICATION_DATA_DIRECTORY/CabbageTest/Soundfiler/Presets/Factory", "*.psts"), userFolder("#USER_APPLICATION_DATA_DIRECTORY/CabbageTest/Soundfiler/Presets/User", "*.psts"), highlightedItemColour(200, 200, 200) highlightedTextColour(25, 25, 25), outlineColour(44, 47, 49), outlineThickness(1), corners(2)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
instr 98
gSfile cabbageGet "LAST_FILE_DROPPED"
if (changed(gSfile) == 1) then
cabbageSet 1, "Soundfiler1", "file", gSfile
endif
endin
instr 1
Sfile cabbageGet "Soundfiler1", "file"
iRegionStart cabbageGetValue "Soundfiler1"
iRegionLength cabbageGetValue "Soundfiler2"
iFileSr filesr gSfile
iFileLengthSeconds filelen gSfile
iFileLengthSamples = iFileLengthSeconds*iFileSr
printk 0.1, iFileLengthSamples // Original length
printk 0.1, iRegionLength // Wrong, too many samples
printk 0.1, iRegionLength * 44100/48000 // Correct amount of samples for me
if filevalid(Sfile) == 1 then
if filenchnls(Sfile) == 1 then
a1 diskin2 Sfile, 1, 0, 1
outs a1, a1
else
a1, a2 diskin2 Sfile, 1, 0, 1
outs a1, a2
endif
endif
endin
</CsInstruments>
<CsScore>
f0 z
i98 0 z
</CsScore>
</CsoundSynthesizer>
Hereās a recording:
Iāll take a look at this in a few days, Iām away from a PC until then. Thanks as always for the test .CSD
Did you get a chance to look at this?
So there was an issue whereby I using the session sample rate to determine various things, which wasnāt correct. Iāve pushed a fix, but have not time to test, would you mind giving it a go? Note one thing, selecting regions with the mouse will always be a little hit or miss because of the resolution of the waveform vs its sample rate. If the soundfiler is displaying a full 1 minute file, and the soundfiler width is 100px, then each mouse click will be quantised to 0.6 seconds. And it gets worse the larger the file.
Thanks, yeah I will test it today
Ok, tested now, and it still seems like thereās something odd with the example I posted previously.
Hereās the file Iām using.
Strange, it looks fine for me here? Iād expect the region length to be somewhat short of the full file length, but itās never longer. Also, Iām surprised this works with mp3, Iād forgotten that Csound now supports them out of the box.
I am on 48k Hz sample rate, are you on the same?
I am now And I see the same issueā¦
[edit] itās strange that it works with 44.1 considering the sample rate of the file is 24kHzā¦
Must be hardcoded to 44.1 somewhere in the soundfiler?
Got it I thinkā¦just testingā¦