Merge branch 'main' into Pitch-bender-and-Portamento

pull/206/head
arsamus 3 years ago committed by GitHub
commit ad6f112dfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/effect_mixer.hpp
  2. 10
      src/mididevice.cpp
  3. 1
      src/minidexed.cpp

@ -89,7 +89,10 @@ public:
AudioStereoMixer(uint16_t len) : AudioMixer<NN>(len)
{
for (uint8_t i=0; i<NN; i++)
panorama[i] = UNITY_PANORAMA;
{
panorama[i][0] = UNITY_PANORAMA;
panorama[i][1] = UNITY_PANORAMA;
}
sumbufR=new float32_t[buffer_length];
arm_fill_f32(0.0f, sumbufR, buffer_length);
@ -108,28 +111,25 @@ public:
pan = MAX_PANORAMA;
else if (pan < MIN_PANORAMA)
pan = MIN_PANORAMA;
panorama[channel] = pan;
// From: https://stackoverflow.com/questions/67062207/how-to-pan-audio-sample-data-naturally
panorama[channel][0]=arm_sin_f32(mapfloat(pan, MIN_PANORAMA, MAX_PANORAMA, 0.0, M_PI/2.0));
panorama[channel][1]=arm_cos_f32(mapfloat(pan, MIN_PANORAMA, MAX_PANORAMA, 0.0, M_PI/2.0));
}
void doAddMix(uint8_t channel, float32_t* in)
{
float32_t tmp[buffer_length];
float32_t sin_pan;
float32_t cos_pan;
assert(in);
// From: https://stackoverflow.com/questions/67062207/how-to-pan-audio-sample-data-naturally
sin_pan=arm_sin_f32(mapfloat(panorama[channel], MIN_PANORAMA, MAX_PANORAMA, 0.0, M_PI/2.0));
cos_pan=arm_cos_f32(mapfloat(panorama[channel], MIN_PANORAMA, MAX_PANORAMA, 0.0, M_PI/2.0));
// left
arm_scale_f32(in, sin_pan, tmp, buffer_length);
arm_scale_f32(in, panorama[channel][0], tmp, buffer_length);
if(multiplier[channel]!=UNITY_GAIN)
arm_scale_f32(tmp,multiplier[channel],tmp,buffer_length);
arm_add_f32(sumbufL, tmp, sumbufL, buffer_length);
// right
arm_scale_f32(in, cos_pan, tmp, buffer_length);
arm_scale_f32(in, panorama[channel][1], tmp, buffer_length);
if(multiplier[channel]!=UNITY_GAIN)
arm_scale_f32(tmp,multiplier[channel],tmp,buffer_length);
arm_add_f32(sumbufR, tmp, sumbufR, buffer_length);
@ -172,7 +172,7 @@ protected:
using AudioMixer<NN>::sumbufL;
using AudioMixer<NN>::multiplier;
using AudioMixer<NN>::buffer_length;
float32_t panorama[NN];
float32_t panorama[NN][2];
float32_t* sumbufR;
};

@ -49,7 +49,8 @@ LOGMODULE ("mididevice");
#define MIDI_PROGRAM_CHANGE 0b1100
#define MIDI_PITCH_BEND 0b1110
#define MIDI_SYSTEM_EXCLUSIVE 0xF0
#define MIDI_SYSTEM_EXCLUSIVE_BEGIN 0xF0
#define MIDI_SYSTEM_EXCLUSIVE_END 0xF7
#define MIDI_TIMING_CLOCK 0xF8
#define MIDI_ACTIVE_SENSING 0xFE
@ -112,7 +113,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
default:
switch(pMessage[0])
{
case MIDI_SYSTEM_EXCLUSIVE:
case MIDI_SYSTEM_EXCLUSIVE_BEGIN:
printf("SysEx data length: [%d]\n",uint16_t(nLength));
printf("SysEx data:\n");
for (uint16_t i = 0; i < nLength; i++)
@ -145,6 +146,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
if (nLength < 2)
{
LOGERR("MIDI message is shorter than 2 bytes!");
return;
}
@ -153,7 +155,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
u8 ucType = ucStatus >> 4;
// GLOBAL MIDI SYSEX
if (pMessage[0] == MIDI_SYSTEM_EXCLUSIVE && pMessage[3] == 0x04 && pMessage[4] == 0x01 && pMessage[nLength-1] == 0xF7) // MASTER VOLUME
if (pMessage[0] == MIDI_SYSTEM_EXCLUSIVE_BEGIN && pMessage[3] == 0x04 && pMessage[4] == 0x01 && pMessage[nLength-1] == MIDI_SYSTEM_EXCLUSIVE_END) // MASTER VOLUME
{
float32_t nMasterVolume=(pMessage[5] & (pMessage[6]<<7))/(1<<14);
LOGNOTE("Master volume: %f",nMasterVolume);
@ -164,7 +166,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
// MIDI SYSEX per MIDI channel
if (ucStatus == MIDI_SYSTEM_EXCLUSIVE && m_ChannelMap[nTG] == pMessage[2] & 0x07)
if (ucStatus == MIDI_SYSTEM_EXCLUSIVE_BEGIN && m_ChannelMap[nTG] == pMessage[2] & 0x07)
HandleSystemExclusive(pMessage, nLength, nTG);
else
{

@ -266,7 +266,6 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
if (m_bUseSerial)
{
m_SerialMIDI.Process ();
m_SerialMIDI.Process ();
}
m_UI.Process ();

Loading…
Cancel
Save