[go: up one dir, main page]

Menu

[r63]: / MolossII / Source / Utils.h  Maximize  Restore  History

Download this file

135 lines (107 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**************************************************************************
Copyright (C) 2019 Arnaud Champenois arthelion@free.fr
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/>.
**************************************************************************/
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
/*!
* Here are all constants for parameters definition
*
*/
#define MOLOSS_VERSION "23.08.11"
constexpr float NoiseMaxGain = 3.0f;
constexpr float LFORamp = 0.2f; // In s
constexpr float LFOMaxSpeed = 10.0f; // In Hz
constexpr float LFOMaxDelay = 5.0f; // In s
constexpr float TVFLowestCutoffFrequency = 10.0f; // In Hz
constexpr float TVFHighestCutoffFrequency = 20500.0f; // In Hz
constexpr float TVFMaxCutoffPower = 3.0f; // same in log10(Hz/20)
constexpr float TVFMaxLowCutPower = 2.5f; // in log10(Hz/20)
constexpr float TVFDefaultResonance = (1.0f / MathConstants<float>::sqrt2);
constexpr float TVFKeyFollowMaxDepth = 0.04f; // in log10(Hz/20) per note
constexpr float TVFMaxResonance = 10.0f;
constexpr float TVFKeyFollowMaxResonance = 0.5f;
constexpr float TVAKeyFollowMaxDepth = 0.014f; // In level unity per note
constexpr float ADSRMinAttackRelease = 0.001f; // in s, to avoid plops
constexpr float ADSRAttackKFMaxDepth = 0.05f; // In s per note
constexpr float ADSRMaxVeloDepth = 1.5f; // We allow to saturate
constexpr float ADSRMaxRelease = 10.0f; // in seconds
constexpr float PitchMaxLFODepth = 5.0f; // In semitones
constexpr float PitchMaxADSRDepth = 12.0f; // In semitones
constexpr float ChorusMinDepth = 0.001f;
constexpr float ChorusMaxDepth = 0.075f;
constexpr float ChorusMinFreq = 0.0f; // in Hz
constexpr float ChorusMaxFreq = 10.0f; // in Hz
constexpr float ChorusFreqFactor = 1.001f; // between left & right LFO
constexpr float ChorusDefaultDelay = 0.004f; // in s
constexpr float MaxDelayTime = 1.0f; // s
// Adjust polyhony here
constexpr int POLYPHONY = 16;
// Number of voices.
// Careful : changing this doesn't automatically add tabs to the GUI !
// The automated gui is not coded...
constexpr int VCO_NUMBER = 4;
// Fake midi values to identify those as controllers, in order to simplify code
constexpr int AftrTouchCtrl = 254;
constexpr int PitchWheelCtrl = 255;
constexpr int ModWheelCtrl = 1;
// Random phase instability
// Sine component
constexpr double RndPhaseShiftPeriodMin = 13.0; // s for one sine drift period
constexpr double RndPhaseShiftPeriodMax = 30.0; // s for one sine drift period
constexpr double RndPhaseSinCoef = 0.001; // max modulation coefficient
// White noise component
constexpr double RndPhaseNoiseCoef = 0.005; // max modulation coefficient
constexpr double KFNoteSplit = 56.0;
/*!
* Appends a counter to a given name
*
* \param name The name
* \param count The counter
* \return <name><counter>
*/
inline std::string countedName(std::string name, int count) {
std::ostringstream sstream;
sstream << name << count;
return sstream.str();
}
class MolossLogger {
#ifdef LOG_FILE
public:
MolossLogger() :
fl(File("D:/Temp/MOLOSS.log"), "Welcome to MOLOSS", 1000)
{}
void log(const String& str) {
fl.logMessage(str);
}
private:
FileLogger fl;
#else
public:
MolossLogger() {}
void log(const String&) {
}
#endif
};
namespace Moloss {
constexpr std::array<const char*, 15> syncStringValues = { "1/32T", "1/32", "1/32D", "1/16T","1/16","1/16D", "1/8T","1/8","1/8D", "1/4T", "1/4","1/4D", "1/2T", "1/2","1/2D" };
constexpr std::array<float, 15> conversionFactor = { 12.0, 8.0, 16.0/3.0, 6.0, 4.0, 8.0/3.0, 3.0, 2.0, 4.0/3.0, 1.5, 1.0, 2.0/3.0, 0.75, 0.5, 1.0/3.0 };
inline float getSyncFreq(float tempo, float normalizedValue, bool inverted) {
if (inverted) normalizedValue = 1.0f - normalizedValue;
int index;
if (normalizedValue == 1.0f)
index = 14;
else
index = floor(conversionFactor.size()*normalizedValue);
return inverted? tempo / 60.0f*conversionFactor[index]: 60.0f / (tempo*conversionFactor[index]);
}
}