-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The MIDI CC mapping can be configured with the file midi-cc.txt on the SD card now. The file format should be self explanatory. A default config file is the config/ directory. Issue #12
- Loading branch information
Showing
10 changed files
with
187 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# MIDI CC Mapping | ||
# | ||
LFOVCOWaveform= | ||
LFOVCOFrequency= | ||
VCOWaveform= | ||
VCOModulationVolume= | ||
VCODetune=94 | ||
LFOVCFWaveform= | ||
LFOVCFFrequency= | ||
VCFCutoffFrequency=74 | ||
VCFResonance=71 | ||
EGVCFAttack= | ||
EGVCFDecay= | ||
EGVCFSustain= | ||
EGVCFRelease= | ||
VCFModulationVolume= | ||
LFOVCAWaveform= | ||
LFOVCAFrequency= | ||
EGVCAAttack= | ||
EGVCADecay= | ||
EGVCASustain= | ||
EGVCARelease= | ||
VCAModulationVolume= | ||
ReverbDecay= | ||
ReverbVolume=91 | ||
SynthVolume=7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// midiccmap.h | ||
// | ||
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi | ||
// Copyright (C) 2021 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
#include "midiccmap.h" | ||
#include "config.h" | ||
#include <assert.h> | ||
|
||
CMIDICCMap::CMIDICCMap (FATFS *pFileSystem) | ||
: m_Properties (DRIVE "/midi-cc.txt", pFileSystem) | ||
{ | ||
for (unsigned i = MIDICC_MIN; i <= MIDICC_MAX; i++) | ||
{ | ||
m_Map[i] = SynthParameterUnknown; | ||
} | ||
} | ||
|
||
CMIDICCMap::~CMIDICCMap (void) | ||
{ | ||
} | ||
|
||
boolean CMIDICCMap::Load (void) | ||
{ | ||
boolean bResult = m_Properties.Load (); | ||
if (!bResult) | ||
{ | ||
m_Properties.RemoveAll (); | ||
} | ||
|
||
for (unsigned i = 0; i < SynthParameterUnknown; i++) | ||
{ | ||
unsigned nMIDICC = | ||
m_Properties.GetNumber (CPatch::GetParameterName ((TSynthParameter) i), 0); | ||
|
||
if (MIDICC_MIN <= nMIDICC && nMIDICC <= MIDICC_MAX) | ||
{ | ||
m_Map[nMIDICC] = (TSynthParameter) i; | ||
} | ||
} | ||
|
||
return bResult; | ||
} | ||
|
||
TSynthParameter CMIDICCMap::Map (u8 ucMIDICC) const | ||
{ | ||
if (MIDICC_MIN <= ucMIDICC && ucMIDICC <= MIDICC_MAX) | ||
{ | ||
return m_Map[ucMIDICC]; | ||
} | ||
|
||
return SynthParameterUnknown; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// midiccmap.h | ||
// | ||
// Maps MIDI CC numbers to TSynthParameter | ||
// | ||
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi | ||
// Copyright (C) 2021 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
#ifndef _midiccmap_h | ||
#define _midiccmap_h | ||
|
||
#include <fatfs/ff.h> | ||
#include <circle/types.h> | ||
#include <Properties/propertiesfatfsfile.h> | ||
#include "patch.h" | ||
|
||
#define MIDICC_MIN 1 | ||
#define MIDICC_MAX 127 | ||
|
||
class CMIDICCMap | ||
{ | ||
public: | ||
CMIDICCMap (FATFS *pFileSystem); | ||
~CMIDICCMap (void); | ||
|
||
boolean Load (void); | ||
|
||
TSynthParameter Map (u8 ucMIDICC) const; | ||
|
||
private: | ||
CPropertiesFatFsFile m_Properties; | ||
|
||
TSynthParameter m_Map[MIDICC_MAX+1]; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// minisynth.cpp | ||
// | ||
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi | ||
// Copyright (C) 2017-2020 R. Stange <[email protected]> | ||
// Copyright (C) 2017-2021 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -133,19 +133,13 @@ boolean CMiniSynthesizer::ConfigUpdated (void) | |
|
||
void CMiniSynthesizer::ControlChange (u8 ucFunction, u8 ucValue) | ||
{ | ||
TSynthParameter Parameter; | ||
|
||
switch (ucFunction) | ||
assert (m_pConfig != 0); | ||
TSynthParameter Parameter = m_pConfig->MapMIDICC (ucFunction); | ||
if (Parameter >= SynthParameterUnknown) | ||
{ | ||
case 7: Parameter = SynthVolume; break; | ||
case 71: Parameter = VCFResonance; break; | ||
case 74: Parameter = VCFCutoffFrequency; break; | ||
|
||
default: | ||
return; | ||
} | ||
|
||
assert (m_pConfig != 0); | ||
CPatch *pPatch = m_pConfig->GetActivePatch (); | ||
assert (pPatch != 0); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// patch.cpp | ||
// | ||
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi | ||
// Copyright (C) 2017-2020 R. Stange <[email protected]> | ||
// Copyright (C) 2017-2021 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -21,7 +21,7 @@ | |
#include "oscillator.h" | ||
#include <assert.h> | ||
|
||
static struct | ||
static const struct | ||
{ | ||
const char *pName; | ||
TParameterType Type; | ||
|
@@ -74,7 +74,7 @@ ParameterList[] = // must match TSynthParameter | |
{"SynthVolume", ParameterPercent, 0, 100, 10, 50, "Volume"} | ||
}; | ||
|
||
static struct | ||
static const struct | ||
{ | ||
const char *pName; | ||
unsigned nMaxLength; | ||
|
@@ -188,9 +188,12 @@ void CPatch::SetParameter (TSynthParameter Parameter, unsigned nValue) | |
void CPatch::SetMIDIParameter (TSynthParameter Parameter, u8 ucValue) | ||
{ | ||
assert (Parameter < SynthParameterUnknown); | ||
assert (ParameterList[Parameter].Type == ParameterPercent); | ||
|
||
unsigned nValue = (ucValue*100 + 63) / 127; | ||
unsigned nValue = ucValue; | ||
nValue *= ParameterList[Parameter].nMaximum - ParameterList[Parameter].nMinimum; | ||
nValue = (nValue + 63) / 127; | ||
nValue += ParameterList[Parameter].nMinimum; | ||
|
||
nValue = (nValue + ParameterList[Parameter].nStep/2) | ||
/ ParameterList[Parameter].nStep | ||
* ParameterList[Parameter].nStep; | ||
|
@@ -262,3 +265,9 @@ const char *CPatch::GetPropertyHelp (TPatchProperty Property) | |
assert (Property < PatchPropertyUnknown); | ||
return PropertyList[Property].pHelp; | ||
} | ||
|
||
const char *CPatch::GetParameterName (TSynthParameter Parameter) | ||
{ | ||
assert (Parameter < SynthParameterUnknown); | ||
return ParameterList[Parameter].pName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// Container for patch settings, loadable from properties file | ||
// | ||
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi | ||
// Copyright (C) 2017-2020 R. Stange <[email protected]> | ||
// Copyright (C) 2017-2021 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -108,6 +108,8 @@ class CPatch | |
static boolean GetPropertyUppercase (TPatchProperty Property); | ||
static const char *GetPropertyHelp (TPatchProperty Property); | ||
|
||
static const char *GetParameterName (TSynthParameter Parameter); | ||
|
||
private: | ||
CPropertiesFatFsFile m_Properties; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// synthconfig.cpp | ||
// | ||
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi | ||
// Copyright (C) 2017-2020 R. Stange <[email protected]> | ||
// Copyright (C) 2017-2021 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -25,7 +25,8 @@ | |
CSynthConfig::CSynthConfig (FATFS *pFileSystem) | ||
: m_pFileSystem (pFileSystem), | ||
m_nActivePatch (0), | ||
m_VelocityCurve (pFileSystem) | ||
m_VelocityCurve (pFileSystem), | ||
m_MIDICCMap (pFileSystem) | ||
{ | ||
for (unsigned i = 0; i < PATCHES; i++) | ||
{ | ||
|
@@ -62,7 +63,11 @@ boolean CSynthConfig::Load (void) | |
assert (m_pPatch[i] != 0); | ||
} | ||
|
||
return m_VelocityCurve.Load (); | ||
boolean bOK = m_VelocityCurve.Load (); | ||
|
||
bOK = m_MIDICCMap.Load () && bOK; | ||
|
||
return bOK; | ||
} | ||
|
||
unsigned CSynthConfig::GetActivePatchNumber (void) const | ||
|
@@ -94,3 +99,8 @@ u8 CSynthConfig::MapVelocity (u8 ucVelocity) const | |
{ | ||
return m_VelocityCurve.MapVelocity (ucVelocity); | ||
} | ||
|
||
TSynthParameter CSynthConfig::MapMIDICC (u8 ucMIDICC) const | ||
{ | ||
return m_MIDICCMap.Map (ucMIDICC); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// Container for global configuration and all patches | ||
// | ||
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi | ||
// Copyright (C) 2017-2020 R. Stange <[email protected]> | ||
// Copyright (C) 2017-2021 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -25,6 +25,7 @@ | |
#include <fatfs/ff.h> | ||
#include "patch.h" | ||
#include "velocitycurve.h" | ||
#include "midiccmap.h" | ||
#include "config.h" | ||
|
||
class CSynthConfig | ||
|
@@ -47,6 +48,7 @@ class CSynthConfig | |
CPatch *GetPatch (unsigned nPatch); | ||
|
||
u8 MapVelocity (u8 ucVelocity) const; | ||
TSynthParameter MapMIDICC (u8 ucMIDICC) const; | ||
|
||
private: | ||
FATFS *m_pFileSystem; | ||
|
@@ -55,6 +57,7 @@ class CSynthConfig | |
unsigned m_nActivePatch; | ||
|
||
CVelocityCurve m_VelocityCurve; | ||
CMIDICCMap m_MIDICCMap; | ||
}; | ||
|
||
#endif |