infinite wave folder

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Joe., luketeaford, lisa, Kent

User avatar
smonkey
Wiggling with Experience
Posts: 259
Joined: Mon Nov 26, 2012 11:39 pm
Location: lost angles (mercury pond)

Post by smonkey » Thu Jun 05, 2014 10:16 pm

Just so ya's know.

You have redeemed my faith in the DIY section of the forum.

I was just lamenting that it mainly "available", "kit", "buy a pcb"
rather than interesting discussions of DIYness

(to be fair, I love kits, pcbs and I like 'em available, I just think there should be a separate for sale section for that shit)

and DIY should be talking about "doing stuff yerself". like discussions of "hw I built this kit" or

well...this beautiful thread here.

well done that man!
"Flingo bungie, whingie FLIP!"

User avatar
plugugly
Common Wiggler
Posts: 217
Joined: Sun Aug 05, 2012 12:08 pm
Location: Dallas, Tx

Post by plugugly » Tue Jun 10, 2014 10:39 am

Agreed.

User avatar
elmegil
Super Deluxe Wiggler
Posts: 2968
Joined: Sun Apr 29, 2012 2:57 pm
Location: Chicago

Post by elmegil » Tue Jun 10, 2014 9:12 pm

Very nice stuff. Wish I had time to experiment with it, I've just gotten interested in wavefolders what with the lockhart in Dustin's Dual Complex VCO.... Will watch closely :)

User avatar
Phetus
Wiggling with Experience
Posts: 292
Joined: Mon Mar 04, 2013 4:33 pm
Location: Berlin

Post by Phetus » Wed Jun 11, 2014 5:22 pm

guest wrote:
Phetus wrote:I'm really interested in the infinite wavefolder. Is there any guinea-pigging to be done? I'd love to help, if I can.
if you have parts kicking around, you could breadboard it and start in on the main problem: slow comparators/switches. right now the whole thing is limited because it takes a few microseconds to slew. doing all the logic on a 5V rail and level shifting would help immensely.
I'm right in thinking I could use 4 TL074s right? I just need 11 Op amps dont I?

Edit: Nope. Ok to be honest i have no idea. I'll come back when I know a bit more.

User avatar
guest
Super Deluxe Wiggler
Posts: 4485
Joined: Mon Aug 19, 2013 11:49 am

Post by guest » Fri Jun 13, 2014 1:07 am

so i finally got a bit of free time and did an implentation of the analog circuit in digital. its actually just a few lines of code it turns out. the AGC isnt implemented, but its a proof of concept.

[video][/video]

its done with an arduino and a codecshield. the codec is running at 44ksps, so top frequency is 20kHz, which is why the edges start rounding off sooner than the analog version (although this should be inaudible).

there is some aliasing from my camera, and there are clicks from the function generator changing ranges.

the 2 main differences between this and the analog: 1. it can easily obtain any frequency up to 20Khz, whereas the analog version needs some serious work to speed up enough. 2. it is much more stable - the analog version had no DC stability, and as such would sometimes lock into these chaotic modes, which had a great sound. sort of a low frequency modulation. perhaps that could be replicated as well.

and here is the code, if anyone is interested. im thinking there must be a better way of doing it that doesnt truncate the data so much. basically, the output is limited to the range set by the wavefolding boundaries. as these boundaries get smaller (and the frequency goes higher), the range of values you can have goes down. in this example, its down to 8 bits.

there werent any "code" insertion buttons, so hopefully this works.

Code: Select all

// setup codec parameters
// must be done before #includes
// see readme file in libraries folder for explanations
#define SAMPLE_RATE 44 // 44.1Khz
#define ADCS 0 // no ADCs are being used

// include necessary libraries
#include <Wire.h>
#include <SPI.h>
#include <AudioCodec.h>

// create data variables for audio transfer
int left_in = 0x0000;
int left_out = 0x0000;
int right_in = 0x0000;
int right_out = 0x0000;

int last_value = 0x0000;
int pos_thresh = 0x0100;
int neg_thresh = -0x0100;
byte state = 0x00;

void setup&#40;&#41; &#123;
  AudioCodec_init&#40;&#41;; // setup codec registers
  // call this last if setting up other parts
&#125;

void loop&#40;&#41; &#123;
  while &#40;1&#41;; // reduces clock jitter
&#125;

// timer1 interrupt routine - all data processed here
ISR&#40;TIMER1_COMPA_vect, ISR_NAKED&#41; &#123; // dont store any registers

  // &'s are necessary on data_in variables
  AudioCodec_data&#40;&left_in, &right_in, left_out, right_out&#41;;
  
  int difference = left_in - last_value;
  last_value = left_in;
  if &#40;state&#41; &#123;
    left_out -= difference;
  &#125;
  else &#123;
    left_out += difference;
  &#125;
  if &#40;left_out >= pos_thresh&#41; &#123;
    state ^= 0x01;
    left_out = pos_thresh - &#40;left_out - pos_thresh&#41;;
  &#125;
  else if &#40;left_out <= neg_thresh&#41; &#123;
    state ^= 0x01;
    left_out = neg_thresh - &#40;left_out - neg_thresh&#41;;
  &#125;

  right_out = left_out << 6;

  // dont forget to return from interrupt
  reti&#40;&#41;;
&#125;
openmusiclabs.com

User avatar
notmiserlouagain
Veteran Wiggler
Posts: 715
Joined: Thu Feb 23, 2012 11:04 am
Location: Hamburg
Contact:

Post by notmiserlouagain » Fri Jun 13, 2014 6:02 am

:yay:
He who eats with most pleasure is he who least requires sauce.
Xenophon

User avatar
Randy
Super Deluxe Wiggler
Posts: 1872
Joined: Sat Sep 22, 2012 9:50 pm
Location: Mississauga, Ontario, Canada

Post by Randy » Fri Jun 13, 2014 8:24 am

Wow, that's cool!

Randy

smrl
Wiggling with Experience
Posts: 429
Joined: Tue Feb 01, 2011 10:09 pm
Location: Milwaukee WI

Post by smrl » Sat Jun 21, 2014 11:00 pm

Played around with this code a little bit with a friend. I suggested we forego the folded output, and try to emulate the CGS VCO staircase generator by incrementing a variable with a "pulse" every time state changes. It continues to increase until it reaches a threshold at which point you return the variable to 0. (discharge the integrator) Scale that signal, and you've got a staircase output which similarly loses bits of information the lower the divisor BUT you can get a very interesting harmonically-related set of pitches out of it. It becomes a ratio generator - input a VCO, a number of folds (the multiplier) and a staircase height (the divisor), and you can derive another output at a just intoned interval.

Probably my biggest interest in wavefolders to date has been to generate these rational-frequency child tones from a VCO. The beauty in this technique, when using an analog multiplier and staircase generator, is that you can get these resultant pitches which track along with the input frequency perfectly. And of course, with a stereo codec, you could generate two different intervals simultaneously! Also, sweeping one or the other parameter makes some very interesting scales and sequences.

I'd post code but we prototyped it in Pippi, his generative music platform built on top of python. I think he's going to port it to C - if not I will, but I just explained it's operation which is really straightforward. I was thinking this might even run on an arduino with its 10-bit ADC into a resistor ladder DAC. That could make a delightfully crude, cheap circuit! Probably it would have to get reduced to 3 or 4 bits at the output to do this. Once again we're trading bit depth for the function. Unless this gives someone any bright ideas.

User avatar
guest
Super Deluxe Wiggler
Posts: 4485
Joined: Mon Aug 19, 2013 11:49 am

Post by guest » Sat Jun 21, 2014 11:10 pm

ha, i just posted about this in the microdec thread. it definitely would be good to have something like that, and the code is quite similar. the codecshield works well, but for a cheaper variant, the stompshield is pretty close. it used the onboard ADC, and a dual PWM output for 16b resolution. all the plans are online, all that would need changing is to make it DC coupled (get rid of blocking caps). i wish i had more time right now to bang out a demo. i thought of another way of doing the math that is more DC stable, and makes the scaling more tractable (no divides!).
openmusiclabs.com

hecanjog
Learning to Wiggle
Posts: 6
Joined: Thu Sep 23, 2010 2:39 pm
Location: milwaukee, wi

Post by hecanjog » Fri Aug 01, 2014 9:59 pm

Hey, I'm the friend smrl mentioned earlier -- this has been so much fun to play with -- thanks so much for sharing it!

I finally got around to moving this into a python C extension today (although I haven't added smrl's staircase variation yet)

Here's a usage example with my janky python computer music system, pippi:

(Pippi can be found here: https://github.com/hecanjog/pippi Be sure to explicitly checkout master after cloning, github seems to select the empty github-pages branch I no longer use by default...)

And a little jamming with a buncha them at once: https://soundcloud.com/hecanjog/wave-folding (whoops also just noticed the silence at the end of the recording after uploading...)

The input for most of it is just a sinewave, but at the end I started throwing arbitrary wavetables at it and increasing the multiplication factor a lot.

User avatar
guest
Super Deluxe Wiggler
Posts: 4485
Joined: Mon Aug 19, 2013 11:49 am

Post by guest » Sat Aug 02, 2014 3:17 am

that sounded awesome. i love how it shimmers, and noisey bit at the end was great.
openmusiclabs.com

User avatar
Neutron7
Oldschool bleeper
Posts: 1964
Joined: Sun May 23, 2010 12:24 pm

Post by Neutron7 » Sat Aug 02, 2014 11:59 am

I will try your code in my teensy 3.1 oscillator, its going at 84khz.

hecanjog
Learning to Wiggle
Posts: 6
Joined: Thu Sep 23, 2010 2:39 pm
Location: milwaukee, wi

Post by hecanjog » Sat Aug 02, 2014 2:48 pm

guest wrote:that sounded awesome. i love how it shimmers, and noisey bit at the end was great.
thanks! i'm looking forward to playing around with it more.

Post Reply

Return to “Music Tech DIY”