TomWhitwell / Chord-Organ

39 stars 21 forks source link

Hyp voicing #4

Closed hyperparallel closed 7 years ago

hyperparallel commented 7 years ago

More options! This is the code to add in voicing. Seems to be working well.

turn it on with !VOICE, knob controls chords and CV controls voicing !VOICE 0 also works !VOICE 1 swaps the inputs

I think the default list of voicings could be better.

I did not implement the second menu with the held button.

Haven't pushed the changes to the more steppy knobs because it keeps breaking the rootCV jacks input.

Normalised commented 7 years ago

Im working through the changes at the moment, could you write some more comments (either here or in the code) about how the vOct / vOctCal setup works and also how the new hysteresis / average works?

Also any chance you could put a compiled binary of this firmware somewhere for testing please. thanks :)

hyperparallel commented 7 years ago

update with a binary :) Didn't know my pull request would get updated with the new stuff I pushed to github, so I didn't add a note. Sorry about that!

The new hysteresis and vOctCal work together..

Calculate the step size for the pots with the same formula you were using.

int indexStep (int range) {
  return (float)ADC_MAX_VAL / (range - 1);
}

The difference is that the hysteresis only returns on a change of the step size. The nice thing is you can never be between notes or steps. (probably). Hysteresis is a percentage of the step size and needs to be greater than 50%. chordHysteresis = chordStep * .70; // 70% Above 55% and it does a pretty good job of removing any jitter. Added the rolling average just to be safe (and for further use).

in indexInputs() {
...
  if (raw > bounceOld + hysteresis) { // going up
    bounceOld += stepSize;
  }else if (raw < bounceOld - hysteresis) { // going down
    bounceOld -= stepSize;
  }      
  if (bounceOld != *bounceValue  ... ) {
    /// We have a new step!

I added a rolling average to each input just to smooth things out a little. I'm sure the size could be altered a little if it slows changes down but I have been happy with it so far. It is called before the hysteresis checking in indexInputs() and alters the ADC number we have. So if you need a smooth ADC reading, it is available after the check. Was think if you wanted to do a non-stepped option you can use this. The average is stored in avgPot[4][128], one slot for each pot and CV and it averages the last 128 readings. Pretty quick and it smooths out the reading a lot.

For the vOctCal, things are slightly different. The step size is multiplied by 4 to get a little more precision before casting to an int. With these large step sizes we can directly add or subtract from them to slightly change the step size. Thats what the number passed to !1VOCT is. Its not linear but we get about 20 extra choices between midi note steps. There is a table in the README that has the values that are the same as some midi notes.

To handle the half size first step I just cut off the negative portion of the step. I was shifting the whole list down a step after that, but I'm just thinking its no longer necessary because I also add 1 to the quantized midi note. Will look into it!

I have been tuning this value by watching my quantizer and controling the root CV. Too small of a value and the chord organ won't change when the quantiser goes up a note.

Planning on implementing the bMenu I wrote for the arpeggiator next. By holding down the button and turning the pots you can change a second value. Going to move all the relative code into a class. Will probably make a class for the button and the leds at the same time.

Normalised commented 7 years ago

Yeah, the way the pull request works is that the branch you use for the request is 'active' for that pull, so anything you push to it gets added to the pull request.

hyperparallel commented 7 years ago

Going to push up the code with the classes added for the controls and the Arp is back in. Thought I would close this first. I put a hex file in there too if you want to check it out. Haven't updated the readme or anything yet. Still want to go back over a few things and debug with fresh eyes.