# miSCellaneous zeroX buffers methods?

dear list,

i was wondering if there could be organizing principles applied to the waveset buffers written by tzeroXbufwr? e.g. ascending indices for waveset lengths or something similar? theres no mention of such methods in the helpfile afaik…?

regards,

jan

Sure, that can be done. The whole business of waveset analysis in the language is already covered by Alberto’s Wavesets class, so I felt no need to duplicate it. Easy analysis (sorting or such) can be done by loading into an array, here’s an example.

``````(
b = Buffer.alloc(s, 4096);
z = Buffer.alloc(s, 100);
)

// analyse a short snippet of ring modulation

(
{
var src = SinOsc.ar(150) * SinOsc.ar(60) + SinOsc.ar(17) * 0.1;
ZeroXBufWr.ar(src, b, z, startWithZeroX: 1, doneAction: 2);
Silent.ar
}.play
)

// plot buffer

b.plot

// zero crossings to lang

z.loadToFloatArray(action: { |b| x = b.reject { |x, i| (x==0) && (i>0) } });

(
// drop last zero crossing
u = x.differentiate.drop(1).drop(-1);

// triples of zeroX sample index, waveset length and zeroX array index
v = [x, u, (0..u.size-1)].flop.sort { |a, b| a[1] <= b[1] };

// zeroX array indices, needed for ZeroXBufRd
w = v.collect(_[2]);
)

// check, higher indices, lower sounds

{ ZeroXBufRd.ar(b, z, zeroX: Dseq(w[0..3], inf)) * 0.5 }.play

{ ZeroXBufRd.ar(b, z, zeroX: Dseq(w[3..6], inf)) * 0.5 }.play

{ ZeroXBufRd.ar(b, z, zeroX: Dseq(w[6..9], inf)) * 0.5 }.play

{ ZeroXBufRd.ar(b, z, zeroX: Dseq(w[9..12], inf)) * 0.5 }.play
``````

Alternatives:

.) write your own analysis Functions or Methods
.) feed data into the Wavesets class and use its methods for analysis
.) start with Wavesets analysis and feed its data into a zeroX buffer

Hope that helps, best

Daniel

Thanks Daniel, got something to learn from that example!
im wondering though how the analysis part could be implemented in a Pspawner set up so to be able to continuously feed & update the buffers from running synths? Maybe somehow implement a routine that can take over the buffer analysis…always find this language maneuvers a bit tricky to combine with pattern control…
Greetings,
Jan

That sounds a bit more demanding, but certainly doable. If you want to continously do new zeroX buffer analysis (and this for usage with Patterns and ZeroXBufRd too?), then I’d separate the analysis from usage, i.e. take two Patterns and establish a bookkeeping for analysis.

would you consider two patterns within one pspawner? and what do you mean by bookkeeping?
all of this is for nrt purposes so the pspawner is sort of a central hub for combining multiple synth/pattern processes, and until now i didnt have to consider analysis methods…

I’m afraid I’m unable to give a concise answer here as too much is unknown (I had RT in mind).

E.g., if you have a data structure bound to one buffer (like length-ordered wavesets), you could want to have a meta structure to store all of them.

You didn’t mention this before and this sounds to me like a game changer. I have no clear idea in mind how to combine NRT with language analysis of audio. Maybe split NRT, do all analysis at beginning (if possible)?

yes unfortunately there’s really plenty of variables to consider with this specific set up. ill try to find my way through these complexities, there surely must be a way to combine these different aspects and include some language analysis within a pattern structure!