From b50a7105bcbaaacb944475e8c9a218eec1b42f48 Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Wed, 19 Sep 2018 20:10:34 +0100 Subject: [PATCH] finalised BufHPSS and BufCompose help files --- .../HelpSource/Classes/FluidBufCompose.schelp | 34 +++++++++++- .../HelpSource/Classes/FluidBufHPSS.schelp | 55 +++++++++++++++++-- src/FluidBufHPSS/tests.scd | 5 +- 3 files changed, 87 insertions(+), 7 deletions(-) diff --git a/release-packaging/HelpSource/Classes/FluidBufCompose.schelp b/release-packaging/HelpSource/Classes/FluidBufCompose.schelp index 8caa4d8..d899e81 100644 --- a/release-packaging/HelpSource/Classes/FluidBufCompose.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufCompose.schelp @@ -83,6 +83,38 @@ DISCUSSION:: EXAMPLES:: code:: -(some example code) +// load some buffers +( +b = Buffer.read(s,"../../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav".resolveRelative); +c = Buffer.read(s,"../../AudioFiles/Tremblay-SA-UprightPianoPedalWide.wav".resolveRelative); +d = Buffer.new(s); +) + +// with basic params (basic summing of each full buffer in all dimensions) +FluidBufCompose.process(s, srcBufNumA: b.bufnum, srcBufNumB: c.bufnum, dstBufNum: d.bufnum); +d.query; +d.play; + +//constructing a mono buffer, with a quiet punch from the synth, with a choked piano resonance from the left channel +FluidBufCompose.process(s, srcBufNumA: b.bufnum, nFramesA: 9000, srcGainA: 0.5, srcBufNumB: c.bufnum, startAtB:30000, nFramesB:44100, nChansB:1, srcGainB:0.9, dstBufNum: d.bufnum); +d.query; +d.play; + +//constructing a stereo buffer, with the end of the mono synth in both channels, with a piano resonance in swapped stereo +FluidBufCompose.process(s, srcBufNumA: b.bufnum, startAtA: 441000, nChansA: 2, srcGainA: 0.6, srcBufNumB: c.bufnum, nFramesB: 80000, startChanB: 1, nChansB: 2, srcGainB: 0.5, dstStartAtB: 22050, dstStartChanB: 0, dstBufNum: d.bufnum); +d.query; +d.play; + +//constructing a one second buffer: the first second of each buffer, the mono synth on the right, the piano on the left +FluidBufCompose.process(s, srcBufNumA: b.bufnum, nFramesA: 44100, nChansA: 1, dstStartChanA: 1, srcBufNumB: c.bufnum, nFramesB:44100, nChansB:1, dstBufNum: d.bufnum); +d.query; +d.play; + +// growing a buffer on itself +e = Buffer.alloc(s,1,1); +FluidBufCompose.process(s,srcBufNumA: b.bufnum, srcBufNumB: e.bufnum, dstBufNum: e.bufnum); +FluidBufCompose.process(s,srcBufNumA: c.bufnum, nChansA: 1, srcBufNumB: e.bufnum, dstBufNum: e.bufnum); +e.plot +e.play :: \ No newline at end of file diff --git a/release-packaging/HelpSource/Classes/FluidBufHPSS.schelp b/release-packaging/HelpSource/Classes/FluidBufHPSS.schelp index 8229b68..0b3afd1 100644 --- a/release-packaging/HelpSource/Classes/FluidBufHPSS.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufHPSS.schelp @@ -110,14 +110,59 @@ RETURNS:: Discussion:: - HPSS works by using median filters on the spectral magnitudes of a sound. It hinges on a simple modelling assumption that tonal components will tend to yield concentrations of energy across time, spread out in frequency, and percussive components will manifest as concentrations of energy across frequency, spread out in time. By using median filters across time and frequency respectively, we get initial esitmates of the tonal-ness / transient-ness of a point in time and frequency.These are then combined into 'masks' that are applied to the orginal spectral data in order to produce a separation. + HPSS works by using median filters on the spectral magnitudes of a sound. It hinges on a simple modelling assumption that tonal components will tend to yield concentrations of energy across time, spread out in frequency, and percussive components will manifest as concentrations of energy across frequency, spread out in time. By using median filters across time and frequency respectively, we get initial esitmates of the tonal-ness / transient-ness of a point in time and frequency. These are then combined into 'masks' that are applied to the orginal spectral data in order to produce a separation. - The modeFlag parameter provides different approaches to combinging estimates and producing masks. Some settings (especially in modes 1 & 2) will provide better separation but with more artefacts.These can, in principle, be ameliorated by applying smoothing filters to the masks before transforming back to the time-domain (not yet implemented). + The modeFlag parameter provides different approaches to combinging estimates and producing masks. Some settings (especially in modes 1 & 2) will provide better separation but with more artefacts. These can, in principle, be ameliorated by applying smoothing filters to the masks before transforming back to the time-domain (not yet implemented). EXAMPLES:: code:: - b = Buffer.read(s,"../../../AudioFiles/01-mix.wav".resolveRelative); - b.play -:: + //load buffers + ( + b = Buffer.read(s,"../../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav".resolveRelative); + c = Buffer.new(s); + d = Buffer.new(s); + e = Buffer.new(s); + ) + + // run with basic parameters + ( + Routine{ + t = Main.elapsedTime; + FluidBufHPSS.process(s, b.bufnum, harmBufNum: c.bufnum, percBufNum: d.bufnum); + s.sync; + (Main.elapsedTime - t).postln; + }.play + ); + + //query and play the harmonic + c.query; + c.play; + //querry and play the percussive + d.query; + d.play; + + //nullsumming tests + {(PlayBuf.ar(1,c.bufnum))+(PlayBuf.ar(1,d.bufnum))+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play + + //more daring parameters, in mode 2 + ( + Routine{ + t = Main.elapsedTime; + FluidBufHPSS.process(s, b.bufnum, harmBufNum: c.bufnum, percBufNum: d.bufnum, resBufNum:e.bufnum, harmFiltSize:31, modeFlag:2); + s.sync; + (Main.elapsedTime - t).postln; + }.play + ); + + //query and play the harmonic + c.query; + c.play; + //query and play the percussive + d.query; + d.play; + //query and play the residual + e.query; + e.play; + :: \ No newline at end of file diff --git a/src/FluidBufHPSS/tests.scd b/src/FluidBufHPSS/tests.scd index 6723d19..249e5c6 100644 --- a/src/FluidBufHPSS/tests.scd +++ b/src/FluidBufHPSS/tests.scd @@ -6,6 +6,7 @@ s.reboot b = Buffer.read(s,"../../release-packaging/AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav".resolveRelative); c = Buffer.new(s); d = Buffer.new(s); +e = Buffer.new(s); ) ( @@ -22,6 +23,8 @@ c.query; c.play; d.query; d.play; +e.query; +e.play; //nullsumming tests {(PlayBuf.ar(1,c.bufnum))+(PlayBuf.ar(1,d.bufnum))+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play @@ -31,7 +34,7 @@ d.play; ( Routine{ t = Main.elapsedTime; - FluidBufHPSS.process(s,b.bufnum, 44100, 44100, 0, 0, c.bufnum, d.bufnum, nil, 51, 31 ,2048,512,4096); // need to change these for something sensible + FluidBufHPSS.process(s,b.bufnum, 44100, 44100, 0, 0, c.bufnum, d.bufnum, e.bufnum, 51, 31, 2); // need to change these for something sensible s.sync; (Main.elapsedTime - t).postln; }.play