Granular Synth Sequencer


For a school project I’m trying to make a granular synth sequencer or arpeggio, based on Peter Knight’s 5pot granular synth . It consists out of 8 steps with corresponding leds and 2 pots per step to change the parameters of the sound. To set the bpm I’m using a rotary encoder and a tiny oled display. Besides I would like to add a start/stop feature for the sequence realised by a switch. Lastly the sound wil be outputted to a jack as shown in Peter Knight’s synth. I’m using an Arduino Mega for this project with all the analog pins being used. 8 out of the 16 potentiometers are Adafruit soft touch pots (4 round and 4 strips), they need a bit of a different approach to normal pots…

I’ve tried to come up with a rough program but it doesn’t work at all, although each seperate part of the project works.

I really hope someone can help me out, cause the project’s deadline is the 18th of January.

Happy New Year!

different_approach_arpeggio2.ino (16.9 KB)

Added fritzing separately because of the file size.

Jeez that's a complex sketch, I don't really know where to start. Here are a few simple things that jump out at me:

  1. variables that might get changed in interrupt service routines should be declared volatile (Bpm).
  2. On line 206 you declare a local variable called Bpm, this is the same name as your global variable Bpm so probably not what you meant to do.
  3. In every case of the switch(LEDStep) block, you assign a value to syncPhaseInc, then assign a different value a couple of lines later without doing anything in between. I don't know what you're trying to do here but that makes no sense.
  4. At the start of loop() you've got a while(1){...} infinite loop that ends a few lines before then last part of loop, so those last few lines of code (starting with the line resetVal=digitalRead(resetButton); ...) never get to run. I don't know why you need that while loop.
  5. I'm not sure those softpots work the way you think they work.

The best way to make a complicated sketch like this is to build it up bit by bit. Make sure what you have is working before adding new features. Otherwise you end up with a huge mess of code that's riddled with errors and when you're not sure about how anything works, it's almost impossible to debug.

Yes, I know the sketch isn't made up well. I will try to build it up bit by bit from the last separate sketches that did work. I'm really new to sound synthesis with Arduino, and i tried to modify Peter Knight's Granular Synth but the code is quiet complex to me. I will try the sequence first with a simple tone mapped to the pots.

But thanks for the feedback!

Interesting project but do you want to be a bit clearer about “it doesn’t work at all”? Do you really mean it does absolutely nothing? If so does it even compile? If not what exactly does it do? And what should it do that’s different?

It’s always possible that a link to the project you’re basing it on might help. You’d probably be amazed how many of us aren’t all that familiar with “Peter Knight’s 5pot granular synth”.


Interesting project but do you want to be a bit clearer about "it doesn't work at all"? Do you really mean it does absolutely nothing? If so does it even compile? If not what exactly does it do? And what should it do that's different?

Just a black screen on the oled and none of the leds are lit up or sequencing. And yes the code compiles, I fixed the issues listed by GypsumFantastic but still nothing changed. It supposed to go through the sequence from led 1 to 8 and read the 2 pots per step and map their value to the parameters to tweak the granular sound per step. Besides that their is a switch to stop and start the sequence and a display with encoder to change the tempo.

Link to Peter Knight's granular synth project:

Possible approach of a Sparkfun project based on Peter Knight's synth, but it's a bit complex and I don't need the button features:

I note a reference to "interrupts". That concerns me for a start - I can't easily read the code because it is attached as a ".ino" file - since I can't see anything here requiring an interrupt. :astonished:

The layout shows a lot of resistors - again, it is anything but obvious what they are there for. :astonished:

That code is way too complicated for me to follow. I can't spot anything that allows for the fact that the SoftPots only cover 1/3rd the range of a standard pot but perhaps it doesn't need to.

Your Fritzy thing has lots of resistors called "pull up" but they all seem to be connected to ground. Again that may be o.k. but it's pull down not up.

If I was trying to test anything like that I'd have Serial.print()s scattered in loads of strategic places so I could see where in the code it was actually getting to.


I note a reference to "interrupts"

Yes I've used 2 interrupts already, one is used for the granular synth and the other one to debounce the rotary encoder.

The layout shows a lot of resistors

There are quiet a few of them, most are used for the 8 softpots as described by Adafruit. It could be confusing as they are drawn as regular ones in Fritzing.

Adafruit's recommendations:

There is a nominal 10K resistance across the two outer leads. The middle pin resistance with respect to either of the outer pins changes depending on where on the strip one presses. When no pressure is applied, the middle pin floats, so be sure to use some sort of weak pullup, such as 100K ohm.

To use Connect one side pin to ground via a 10K resistor in series. Connect the other side pin to your Vcc power line (3V, 5V etc) via a different 10K resistor in series. Then read the analog voltage on the center pin. It will range from 1/3 Vcc to 2/3 Vcc . Do not connect to Ground and Power directly!

I've tested them in pull down configuration and they do read the 2/3 Vcc in the serial monitor.

And yes, I will try to build the sketch up bit by bit as stated above while monitoring the pot values.