Re: Number of transmitted poly channels
Posted: Wed Jan 01, 2025 6:28 pm
Sounds good!
A place to discuss Cherry Audio and Voltage Modular
https://forums.cherryaudio.com/
Code: Select all
if (inputJackV1.IsConnected())
{
// Read analogue input V1
tmpFloat = (float)inputJackV1.GetValue();
// Restrict to range +/- 8.0V and add 8.0 to make range 0.0 to 16.0
tmpFloat = 8.0f + Math.min(8.0f, Math.max(-8.0f, tmpFloat));
// Convert to int in range 0 to 16,000
tmpFloat *= 1000.0f;
tmpFloat += 0.5f;
tmpInt = (int)tmpFloat; // No need to use Math.Floor as all values are positive
// Check if a change in value has occurred.
if (previousAnalogueValue[0] != tmpInt)
{
ShortMessage analogue14Bit1 = new ShortMessage();
// Record value for next iteration of ProcessSample
previousAnalogueValue[0] = tmpInt;
// Split value into two 7-bit numbers
intParam1 = (tmpInt & 0x3F80) >> 7; // MS 'Byte'
intParam2 = (tmpInt & 0x007F); // LS 'Byte'
try
{
analogue14Bit1.setMessage(ShortMessage.CONTROL_CHANGE, 0, intParam1, intParam2);
}
catch (InvalidMidiDataException e)
{
// Do nothing for time being
}
midiOutputJack1.AddMessage(analogue14Bit1);
}
}
Code: Select all
// Process any pending MIDI input stream messages
ArrayList<ShortMessage> events = midiInputJack1.GetMessages();
// events will be non-null if there are
// MIDI events to process
if (events != null)
{
int numEvents = events.size();
for (int ix = 0; ix < numEvents; ix++)
{
ShortMessage event = events.get(ix);
int command = event.getCommand();
if (command == ShortMessage.CONTROL_CHANGE)
{
midiChannel = event.getChannel();
intParam1 = event.getData1();
intParam2 = event.getData2();
if (midiChannel < 8)
{
// Analogue channel 1 to 8
tmpInt = (intParam1 << 7) + intParam2;
tmpDouble = ((double)tmpInt * 0.001) - 8.0;
analogueOutputValue[midiChannel] = tmpDouble;
}
else
{
// Digital channel 15 or 16
if (midiChannel == 14)
{
ch15Param1 = intParam1;
ch15Param2 = intParam2;
tmpInt = (intParam1 << 7) + intParam2;
tmpDouble = (double)tmpInt * 0.0006510417;
analogueOutput15 = tmpDouble;
updateCh15 = true;
}
else if (midiChannel == 15)
{
ch16Param1 = intParam1;
ch16Param2 = intParam2;
tmpInt = (intParam1 << 7) + intParam2;
tmpDouble = (double)tmpInt * 0.0006510417;
analogueOutput16 = tmpDouble;
updateCh16 = true;
}
}
} // End of if (command == ShortMessage.CONTROL_CHANGE)
} // End of for (int ix=0; ix < numEvents; ix++)
} // End of if (events!= null)
Hi Colin,