Skip to content

Commit

Permalink
handle disconnected Scale inpput
Browse files Browse the repository at this point in the history
  • Loading branch information
chinenual committed Apr 14, 2024
1 parent eb861f8 commit 023e15d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2.7.0-beta2

* Changed Harp output polyphony to 16 channels (was only 5 in beta1).
* Handled unconnected Scale input in Harp - treat as a chromatic scale rooted at C4.

## 2.7.0-beta1

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ This is that specialized software.

Inputs:

* **Scale** - Defines the notes of the scale to be strummed (V/Oct, polyphonic). Channel 0 is treated as the "root" of the strum range. The expected format is compatible with docB's Gen Scale and Aaron Static's ScaleCV modules.
* **Scale** - Defines the notes of the scale to be strummed (V/Oct, polyphonic). Channel 0 is treated as the "root" of the strum range. The expected format is compatible with docB's Gen Scale and Aaron Static's ScaleCV modules. If unconnected, the Harp uses a chromatic scale rooted at C4.

* **Pitch** - The CV signal from the control surface. Not V/Oct; just a continous range of voltage that corresponds to where the musicians fingers are touching the control surface. Valid voltage range is determined by context menu (see below).

Expand Down
18 changes: 15 additions & 3 deletions src/Harp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,22 @@ namespace Harp {
auto inputCvMin = MIDIRecorder::CVRanges[cvConfigPitch].low;
auto inputCvMax = MIDIRecorder::CVRanges[cvConfigPitch].high;
int s = std::round((v - inputCvMin) / (inputCvMax - inputCvMin) * (noteRange-1));
int degree = s % inputs[SCALE_INPUT].getChannels();
int octave = s / inputs[SCALE_INPUT].getChannels();
float scaledPitch;
int scaleSize = 11; // default to chromatic
if (inputs[SCALE_INPUT].isConnected()) {
scaleSize = inputs[SCALE_INPUT].getChannels();
scaledPitch = inputs[SCALE_INPUT].getPolyVoltage(degree);
}
int degree = s % scaleSize;
int octave = s / scaleSize;
if (! inputs[SCALE_INPUT].isConnected()) {
// default is chromatic with root at C4
const float C4 = 0.0f;
const float SEMITONE = 1.0f/12.f;
scaledPitch = C4 + (degree * SEMITONE);
}
//INFO("note: r:%d pi:%d s:%d d:%d o:%d",noteRange, cvConfigPitch,s,degree,octave);
currNote = inputs[SCALE_INPUT].getPolyVoltage(degree) + (octave * 1.f);
currNote = scaledPitch + (octave * 1.f);
}

if (notePlaying) {
Expand Down

0 comments on commit 023e15d

Please sign in to comment.