View Single Post
Old 06-12-2006, 09:12 AM   #108
Youn
Human being with feelings
 
Youn's Avatar
 
Join Date: Jun 2006
Posts: 1,168
Default Sample Trigger

I just started using Jesusonic a few days ago and made this script, it's rather crude and samples need to be the same sample rate as project and they need to be stereo and not too long (though I had success with 4 second long samples!) here's the code, you can copy and paste as a new effect, make a directory in "data" folder and throw samples in. Also note changing samples during playback doesn't work too well. Again, rather crude, but it works and have used it in a few songs already (saved me from having to load up Logic to do this exact thing)...



desc: Simple Sample Trigger (mono)
slider1:/samples:none:Sample
slider2:-6<-30,0,0.5>threshold (db)
slider3:150<0,300,10>release time (ms)

@init
releaseCount = 0;
samplePos = 0;

@slider
thresh = 2 ^ (slider2/6);
releaseTime = slider3 * srate / 1000;
lastslider1 != (slider1|0) ? (
lastslider1=slider1|0;
filehandle = file_open(slider1);
sample_len = sample_nch = sample_srate = 0;
filehandle > 0 ? (
file_riff(filehandle, sample_nch, sample_srate);
sample_nch ? (
sample_len = file_avail(filehandle)/sample_nch;
file_mem(filehandle, sample, sample_len * sample_nch);
samplePos = sample_len;
);
file_close(filehandle);
);
);

@sample

overThresh = (abs(spl0) > thresh) || (abs(spl1) > thresh);
overThresh && !releasing ? (
samplePos = 0;
releaseCount = 0;
releasing = 1;
);

spl0 = sample[samplePos*2];
spl1 = sample[samplePos*2]; // how do we do stereo?
samplePos += 1;
(releaseCount += 1) > releaseTime ? releasing = 0;
Youn is offline   Reply With Quote