forked from supercollider/sc3-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jonatan Liljedahl <[email protected]>
- Loading branch information
Showing
11 changed files
with
734 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
source/BBCut2UGens/sc/HelpSource/Classes/AnalyseEvents2.schelp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class:: AnalyseEvents2 | ||
summary:: event analyser (BBCut) | ||
related:: Classes/AutoTrack | ||
categories:: UGens>Analysis | ||
|
||
|
||
Description:: | ||
|
||
code:: | ||
//This file is part of MLfftwUGens. Copyright (C) 2006 Nicholas M.Collins distributed under the terms of the GNU General Public License full notice in file MachineListening.license | ||
|
||
//This file is part of The BBCut Library. Copyright (C) 2001 Nick M.Collins distributed under the terms of the GNU General Public License full notice in file BBCutLibrary.help | ||
:: | ||
|
||
On-the-fly event analyser, based on onset detection/on-the-fly analysis described in my academic papers. Best for percussive events. Recommended that you go via the link::Classes/Segmentation:: (for one-pass) and link::Classes/AnalyseEventsDatabase:: (for on-the-fly) classes in standard usage, don't use this directly. | ||
|
||
note:: | ||
you will need bbcut2 for further classes and capabilities. This UGen is included in sc3-plugins for cross-platform building. | ||
:: | ||
|
||
classmethods:: | ||
|
||
method::ar | ||
|
||
argument::in | ||
Audio input to track | ||
|
||
argument::bufnum | ||
A buffer within which results of the analysis are place | ||
|
||
argument::threshold | ||
A parameter acting as the onset detector threshold, default of 0.34 was determined as the best performing over a database of percussive onset, but you might want to change this to change the sensitivity (though you always increase the risk of false positives or false negatives) | ||
|
||
argument::triggerid | ||
A trigger ID number used for communication from the UGen to the Lang to mark that a new event was received. Only passed for on-the-fly analysis. | ||
|
||
argument::circular | ||
A flag to note on-the-fly analysis assuming a circular buffer. If you only need a one-pass analysis on a file, you won't use this. | ||
|
||
argument::pitch | ||
Can take a .kr pitch detection UGen as input. Will take the median fundamental frequency over a note event from values recorded from this pitch input. | ||
|
||
|
||
Examples:: | ||
|
||
No examples are given, to discourage solo use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
class:: AutoTrack | ||
summary:: autocorrelation beat tracker | ||
related:: Classes/AnalyseEvents2, Classes/BeatTrack | ||
categories:: UGens>Analysis | ||
|
||
|
||
Description:: | ||
|
||
note:: | ||
synonym for link::Classes/BeatTrack:: these days, since BeatTrack went in core | ||
:: | ||
|
||
Autocorrelation beat tracker by Nick Collins, following: | ||
|
||
M. E. P. Davies and M. D. Plumbley. Beat Tracking With A Two State Model. emphasis::Proceedings of the IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP 2005)::, Philadelphia, USA, March 19-23, 2005 | ||
|
||
This is my own adaptation for my beat tracking research and uses my own C implementation of Matthew Davies' original MATLAB model. Meanwhile, Paul Brossier and Matthew have been preparing their own realtime version for Paul's aubio library. | ||
|
||
There are four k-rate outputs, being ticks at quarter, eighth and sixteenth level from the determined beat, and the current detected tempo. | ||
|
||
Note the following restrictions: | ||
|
||
This beat tracker determines the beat, biased to the midtempo range by weighting functions. It does not determine the measure level, only a tactus. It is also slow reacting, using a 6 second temporal window for it's autocorrelation maneouvres. Don't expect human musician level predictive tracking. | ||
|
||
On the other hand, it is tireless, relatively general (though obviously best at transient 4/4 heavy material without much expressive tempo variation), and can form the basis of computer processing that is decidedly faster than human. | ||
|
||
|
||
classmethods:: | ||
|
||
method::kr | ||
|
||
argument::in | ||
Audio input to track | ||
|
||
argument::lock | ||
If this argument is greater than 0.5, the tracker will lock at its current periodicity and continue from the current phase. Whilst it updates the model's phase and period, this is not reflected in the output until lock goes back below 0.5. | ||
|
||
|
||
Examples:: | ||
|
||
code:: | ||
//choose some file you want to track off your hard drive (mono) | ||
b=Buffer.read(s,"/data/audio/mirdata/stevebeattrack/samples/100.wav"); | ||
|
||
( | ||
a= SynthDef(\help_autotrack,{arg vol=1.0, beepvol=1.0, lock=0; | ||
var trackb,trackh,trackq,tempo; | ||
var source, beep; | ||
|
||
source= PlayBuf.ar(1,b.bufnum,1.0,1,0,1); | ||
|
||
#trackb,trackh,trackq,tempo=AutoTrack.kr(source, lock); | ||
|
||
beep= SinOsc.ar(1000,0.0,Decay.kr(trackb,0.1)); | ||
|
||
Out.ar(0,Pan2.ar((vol*source)+(beepvol*beep),0.0)); | ||
|
||
}).play; | ||
) | ||
|
||
a.set(\vol,0.0); | ||
|
||
a.set(\beepvol,1.0); | ||
|
||
a.set(\lock,1); //fix it rigidly from current phase/period solution | ||
|
||
a.set(\lock,0); //unfix, back to tracking | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//track audio in (try clapping a beat or beatboxing, but allow up to 6 seconds for tracking to begin) and spawning stuff at quarters, eighths and sixteenths | ||
( | ||
SynthDef(\help_autotrack2,{ | ||
var trackb,trackh,trackq,tempo; | ||
var source; | ||
var bsound,hsound,qsound; | ||
|
||
source= SoundIn.ar; | ||
|
||
#trackb,trackh,trackq,tempo=AutoTrack.kr(source); | ||
|
||
bsound= Pan2.ar(LPF.ar(WhiteNoise.ar*(Decay.kr(trackb,0.05)),1000),0.0); | ||
|
||
hsound= Pan2.ar(BPF.ar(WhiteNoise.ar*(Decay.kr(trackh,0.05)),3000,0.66),-0.5); | ||
|
||
qsound= Pan2.ar(HPF.ar(WhiteNoise.ar*(Decay.kr(trackq,0.05)),5000),0.5); | ||
|
||
Out.ar(0, bsound+hsound+qsound); | ||
}).play; | ||
) | ||
:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
class:: Concat | ||
summary:: Concatenative Cross-Synthesis on Live Streams | ||
related:: Classes/Concat2 | ||
categories:: UGens>GranularSynthesis | ||
|
||
|
||
Description:: | ||
|
||
Implementation of concatenative sound synthesis based on matching four features from a control input to the database generated from a source input. The control determines which frames of the source get played back, and you can change the weighting of features to refine your matching criteria (ie, make rms the most heavily weighted to have amplitude as the most important criteria). You can also modulate the match length, being the amount of source played back for a match, the feature weightings, and freeze the database collection to work with a collected sample from the source. | ||
|
||
Refs- see the publications of Schwarz, Sturm, Casey amongst others. | ||
|
||
classmethods:: | ||
|
||
method::ar | ||
|
||
argument::control | ||
audio rate input, acts as control | ||
|
||
argument::source | ||
audio rate input, source for cross-synthesis | ||
|
||
argument::storesize | ||
size of source store sample buffer in seconds | ||
|
||
argument::seektime | ||
Time in seconds into the past to start searching for matches | ||
|
||
argument::seekdur | ||
Time in seconds from seektime towards the present to test matches | ||
|
||
argument::matchlength | ||
Match length in seconds (this will be rounded to the nearest FFT frame) | ||
|
||
argument::freezestore | ||
Stop collecting novel source input, keep store (database) fixed | ||
|
||
argument::zcr | ||
Weight for zero crossing rate feature | ||
|
||
argument::lms | ||
Weight for log mean square amplitude feature | ||
|
||
argument::sc | ||
Weight for spectral centroid feature | ||
|
||
argument::st | ||
Weight for spectral tilt feature | ||
|
||
|
||
Examples:: | ||
|
||
code:: | ||
b = Buffer.read(s,"sounds/a11wlk01.wav"); | ||
|
||
|
||
//match only on amplitude from audio in | ||
( | ||
SynthDef(\concat1, {arg bufnum, matchlength=0.01, freeze=0; | ||
var concat, control, input; | ||
|
||
control= SoundIn.ar; | ||
|
||
input=PlayBuf.ar(1,bufnum,BufRateScale.kr(bufnum), loop:1); | ||
|
||
concat= Concat.ar(control,input,1.0,1.0,1.0,matchlength,freeze,0.0,1.0,0.0,0.0); | ||
|
||
Out.ar(0,Pan2.ar(concat,0.0))}).add; | ||
) | ||
|
||
a=Synth(\concat1,[\bufnum, b.bufnum]); | ||
|
||
a.set(\freeze, 0); | ||
|
||
a.set(\matchlength, 0.01); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//synthesis controls audio in- beat box, then the synth drives bits of audio rhythmically | ||
( | ||
{ | ||
var concat, control, input; | ||
|
||
control= SinOsc.ar(0.5)*Saw.ar(SinOsc.kr(LFNoise0.kr(MouseY.kr(0.01,1),3,4.5),0,50,MouseY.kr(120,500))); | ||
|
||
input=SoundIn.ar; | ||
|
||
concat= Concat.ar(control,input,4.0,4.0,4.0,MouseX.kr(0.0,0.5),0,0.5,1.0,0.5,0.0); | ||
|
||
Out.ar(0,Pan2.ar(concat,0.0))}.play | ||
) | ||
|
||
|
||
|
||
//audio in controls synthesis, low latency, match by ZCR and spec centroid | ||
( | ||
{ | ||
var concat, control, input, amp; | ||
|
||
input= SinOsc.ar(2)* | ||
Mix(Gendy3.ar(3,5,1.0,1.0,(Array.fill(5,{LFNoise0.kr(1.3.rand,1,2)})*MouseY.kr(100,3780,'exponential')),MouseY.kr(0.01,0.05),MouseY.kr(0.001,0.016),5,mul:0.1)); | ||
|
||
control=SoundIn.ar; | ||
|
||
amp=Amplitude.ar(control); | ||
|
||
concat= Concat.ar(control,input,1.0,1.0,1.0,MouseX.kr(0.0,0.1),0,1.0,0.0,1.0,1.0); | ||
|
||
Out.ar(0,Pan2.ar(10*concat*amp,0.0))}.play | ||
) | ||
|
||
|
||
|
||
//granulator | ||
( | ||
{ | ||
var concat, control, input; | ||
|
||
control= Saw.ar(SinOsc.kr(LFNoise0.kr(MouseY.kr(0.01,1),3,4.5),0,10,MouseY.kr(12,100))); | ||
|
||
input=PlayBuf.ar(1,b.bufnum,BufRateScale.kr(b.bufnum), loop:1); | ||
|
||
concat= Concat.ar(control,input,2.0,2.0,2.0,MouseX.kr(0.01,0.1),0,MouseY.kr(0.0,1.0),1.0,0.5); | ||
|
||
Out.ar(0,Pan2.ar(concat,0.0))}.play | ||
) | ||
|
||
|
||
|
||
|
||
|
||
b = Buffer.read(s,"sounds/break2"); | ||
|
||
|
||
//beat resynthesis match by ZCR and spec centroid | ||
( | ||
SynthDef(\concatexample2, {arg bufnum, freeze=0; | ||
var concat, control, input, amp; | ||
|
||
input= SoundIn.ar; | ||
|
||
control=PlayBuf.ar(1,bufnum,BufRateScale.kr(bufnum), loop:1); | ||
|
||
amp=Amplitude.ar(control); | ||
|
||
concat= Concat.ar(control,input,5.0,5.0,5.0,MouseX.kr(0.0,0.1),freeze,MouseY.kr(0.0,1.0),0.0,1.0); | ||
|
||
Out.ar(0,Pan2.ar(10*concat*amp,0.0)) | ||
}).add; | ||
) | ||
|
||
|
||
a=Synth(\concatexample2,[\bufnum, b.bufnum]); | ||
|
||
a.set(\freeze, 1); //set this on or off to stay with a set of collected sounds | ||
|
||
a.set(\freeze, 0); //set this on or off to stay with a set of collected sounds | ||
:: |
Oops, something went wrong.