Rounding potentiometer input...

Hey all, I am currently working on an eight step sequencer/synth with my arduino. I have a pot to control frequency but I would like to only have musical notes. At the moment I am using the freqout function in the playground, but I am just feeding it the value from the pot directly.

Obviously, I won't be able to fit nine octaves of 12 notes each on a single pot, so some sort of modifier will be needed (a button to cycle through octaves or another pot with its input divided into 9 sections)

A modifier pot should be easy, simply have the main pitch pot value being turned into the highest octave and then divide it by powers of two for each octave down that the modifier is set to.

Any help towards having only musical notes played preferably with one octave on the pitch pot and a modifier would be greatly appreciated.

I hope I have made sense...

Cheers

You could hook up a rotary switch with a bunch of resistors to an analog in, and use that as your octave selector.

For each octave you would have a base number that you would add to for the frequency of the actual notes selected with the pot.

When you read the value of the pot you test the value read and check wether it is in one of 12 intervals. If it is is anywhere in the interval you play a specifik note.

Thanks! That's pretty much what I just started working on...

85.25 A
-----------------------------127.9 if above this,
170.5 A#
-----------------------------213.15 and below this, make it A#
255.75 B
---------------------------298.4
341 C
--------------------------383.65
etc..

Then do "if frequency is A then send the musical frequency A to the freqout function".

Rotary switch sounds like the way to go, but I don't have any at present so I will hook up another pot and divide it up similarly to above.

Once I clean it up a bit and perhaps set up some LEDs (I have none at the moment :o) I will post the layout and code if anyone is interested.

Cheers

Why bother with a rotary switch? Just have a second pot with a very quantised range? e.g.map (analogRead(rangePot), 0, 1023, 1, 9);

Or do you need the physical detent of a rotary switch?

Yeah a pot will work in stead of the rotary switch i suggested.

The physical action is the only reason I would want the rotary switch and only for the "feel".

Your method looks much better and really simplifies things compared to how I was doing it. I will update my code to use this method for both the octave and the pitch potentiometer usage.

Thank you, Groove, this seems like a very useful 'trick' that I didn't know before.