Page 4 of 5

Re: sound freezer

Posted: Thu May 01, 2014 7:31 pm
by tester
So in order to get the mem to array - it would have to be something like this?

//edit: pre-finale version.

Re: sound freezer

Posted: Thu May 01, 2014 7:57 pm
by tester
Okay, it seems this little fellow works.
Thanks KG!

Re: sound freezer

Posted: Thu May 01, 2014 11:22 pm
by tester
Okay, it appears that combined - it works, but... not as it should. Could you play with it a little bit? The design to which I'd like to integrate that stuff is posted here few posts earlier (temp.fsm).

p.s.:
Best way would be to focus the wave capture on zero crosspoint I guess.

Re: sound freezer

Posted: Sat May 03, 2014 6:42 pm
by tester
Okay, I'm stuck.

1) Probably, there is no way to get sample accurate loop using waveread and wavewrite combined with selector, because selector is switched via greenery.

2) Plus - it would be better/recommended, to get the single-cycle wave file that is captured between zero-crossing points, and not randomly.

*

Question 1. How to capture and save to file - sample-accurate, single-cycle wave - from a stream? In this scenario - start/stop flipflop reference would be minus-to-plus change in the stream.

Question 2. Predicting that the single-cycle wave in the stream - may contain multiple zero crossings - how to capture what described above - having the "cycle lenght"? In this scenario - start would be the first minus-to-plus encountered, and stop would be after specified cycle lenght.

Re: sound freezer

Posted: Sat May 03, 2014 10:05 pm
by KG_is_back
trogs float-array to mem experiment may help. basically it uses ruby to create a predefined-sized buffer (a sample frame) and sends its address as a value to assembler primitive. in assembler you can use this address in pretty much the same way you use arrays (write and read from it).
advantage over wave read/write is, that you can use jump commands to bypass both writing and reading.
disadvantages are that you'll need to write a lot of parts in assembly and also the initialization is quite unstable (even to a degree that the schematic cannot be loaded because it crashes on startup).
I may provide example later this evening...

Re: sound freezer

Posted: Sat May 03, 2014 10:18 pm
by tester
I'm starting to wonder about something else.

Here is the idea, I'm not sure how to compile it.

If indexes are in blue, driven by ramp, then ramp may be triggered once, by stream/blue change from minus to plus.

Ramp would be stopped and hold (thus - indexes would be stopped and hold) after reaching certain threshold (calculated from "lenght").

All happens in "read" mode, with no need to use selector. Because - there is a prim called mem to array. Thus - the loop would be stored directly as a text/shape. This array can be resampled then easily.

Second idea that comes to my mind - is to use the "lenght minus n%" (related to single precision accuracy) to open the way to stop the ramp - after reaching next closes minus to plus crossing.

Does it makes any sense? Is my understanding correct here?

Re: sound freezer

Posted: Sat May 03, 2014 10:41 pm
by KG_is_back
yes, the ramp may be activated on first found zero crossing and stopped one sample after next zero crossing (or a first zero crossing after some "minimal period" length). Then only the desired part of mem would be read, because period would be found ... I'm actually working on that right now.

Re: sound freezer

Posted: Sun May 04, 2014 12:05 am
by KG_is_back
Here... a working prototype

Re: sound freezer

Posted: Sun May 04, 2014 2:12 am
by tester
Thanks for effort.

Now - from what I can see - buffer can be reduced to 20000 if I understand it correctly.
From what I can see - buffer should not (or?) be changed during schematic running (invisible 100% CPU may happen).

So. Let say that I'm using Martin's crossfaded freezer, and I have frozen the sound.
I'm turning on (triggering) your prototype, to capture a sample of that sound.
Loop lenght = buffer * 1000/pitch in miliseconds; buffer = 1, so actually it's not in the equation.
(I'm not sure about the accuracy of lenght, so let say stop point should be found around "lenght - 1%"? Or?).

What should stop the prototype?
How do I get the captured sound (single cycle wave, sample accurate) to wav or text file? (mem2floatarray shows strange results)

Re: sound freezer

Posted: Sun May 04, 2014 2:26 am
by KG_is_back
in my schematic in off state the freezer writes data to index [0] and reads from index[0] afterwards. In writing mode it writes to indexes 1,2,3,... until zero crossing is found and looping mode turns on. In looping mode it writes to index [0] and reads indexes [0] to period length.
the memory is fixed size - to save one period from it you have to extract section [0] to [period length].

note that there is a parameter which defines the minimum period length (basically defines how long is the algorithm latent after finding first zero crossing and stating to search for the second one). That should be calculated with from the pitch of your signal and some "tolerance" like:
minimal period length [in samples]=0.99[tolerance of 1%]*2/f[normalized frequency]