Vital
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4
5// Debugging assertions.
6// For debug builds, VITAL_ASSERT(x) behaves like assert(x), otherwise it's a no-op.
7#if DEBUG
8#include <cassert>
9#define VITAL_ASSERT(x) assert(x)
10#else
11#define VITAL_ASSERT(x) ((void)0)
12#endif // DEBUG
13
14// Marks a variable or parameter as unused to avoid compiler warnings.
15#define UNUSED(x) ((void)x)
16
17// Force inline macros for compilers.
18#if !defined(force_inline)
19#if defined (_MSC_VER)
20#define force_inline __forceinline
21 #define vector_call __vectorcall
22#else
23#define force_inline inline __attribute__((always_inline))
24#define vector_call
25#endif
26#endif
27
28#include "poly_values.h"
29
30namespace vital {
31
32 // The base floating-point type for monophonic calculations.
33 typedef float mono_float;
34
35 // Mathematical and audio-related constants used throughout the synthesis framework.
36 constexpr mono_float kPi = 3.1415926535897932384626433832795f;
37 constexpr mono_float kSqrt2 = 1.414213562373095048801688724209698f;
38 constexpr mono_float kEpsilon = 1e-16f;
39 constexpr int kMaxBufferSize = 128;
40 constexpr int kMaxOversample = 8;
41 constexpr int kDefaultSampleRate = 44100;
42 constexpr mono_float kMinNyquistMult = 0.45351473923f;
43 constexpr int kMaxSampleRate = 192000;
44 constexpr int kMidiSize = 128;
45 constexpr int kMidiTrackCenter = 60;
46
47 constexpr mono_float kMidi0Frequency = 8.1757989156f;
48 constexpr mono_float kDbfsIncrease = 6.0f;
49 constexpr int kDegreesPerCycle = 360;
50 constexpr int kMsPerSec = 1000;
51 constexpr int kNotesPerOctave = 12;
52 constexpr int kCentsPerNote = 100;
54
55 constexpr int kPpq = 960;
56 constexpr mono_float kVoiceKillTime = 0.05f;
57 constexpr int kNumMidiChannels = 16;
58 constexpr int kFirstMidiChannel = 0;
59 constexpr int kLastMidiChannel = kNumMidiChannels - 1;
60
84} // namespace vital
85
Contains classes and functions used within the Vital synthesizer framework.
VoiceEvent
Enumerates different states or events of a synth voice's lifecycle.
Definition common.h:74
@ kVoiceIdle
Definition common.h:76
@ kInvalid
Definition common.h:75
@ kVoiceOn
Definition common.h:77
@ kVoiceKill
Definition common.h:81
@ kNumVoiceEvents
Definition common.h:82
@ kVoiceDecay
Definition common.h:79
@ kVoiceHold
Definition common.h:78
@ kVoiceOff
Definition common.h:80
constexpr int kMaxBufferSize
Maximum buffer size for processing.
Definition common.h:39
constexpr int kMsPerSec
Milliseconds per second.
Definition common.h:50
constexpr int kNumMidiChannels
MIDI channels available per device.
Definition common.h:57
constexpr int kLastMidiChannel
The last MIDI channel index.
Definition common.h:59
constexpr int kPpq
Pulses per quarter note used internally.
Definition common.h:55
constexpr int kDefaultSampleRate
Default sample rate in Hz.
Definition common.h:41
constexpr mono_float kSqrt2
Square root of 2.
Definition common.h:37
constexpr mono_float kMidi0Frequency
Frequency of MIDI note 0 (C-1).
Definition common.h:47
constexpr int kNotesPerOctave
Number of semitones per octave.
Definition common.h:51
constexpr int kCentsPerOctave
Cents per octave (1200).
Definition common.h:53
constexpr mono_float kMinNyquistMult
Minimum ratio relative to Nyquist frequency.
Definition common.h:42
constexpr int kDegreesPerCycle
Degrees in a full rotation (for LFO phases).
Definition common.h:49
constexpr int kFirstMidiChannel
The first MIDI channel index.
Definition common.h:58
constexpr int kMidiSize
MIDI note count (0-127).
Definition common.h:44
constexpr mono_float kPi
Pi constant.
Definition common.h:36
constexpr int kMidiTrackCenter
MIDI note considered as center (Middle C).
Definition common.h:45
constexpr int kCentsPerNote
Number of cents per semitone.
Definition common.h:52
constexpr mono_float kDbfsIncrease
A gain increase of 6 dB.
Definition common.h:48
constexpr int kMaxSampleRate
Maximum expected sample rate in Hz.
Definition common.h:43
constexpr mono_float kVoiceKillTime
Time in seconds after which a silent voice is considered dead.
Definition common.h:56
constexpr int kMaxOversample
Maximum allowed oversampling factor.
Definition common.h:40
constexpr mono_float kEpsilon
A small epsilon for floating comparisons.
Definition common.h:38
float mono_float
Definition common.h:33
Defines SIMD-based vectorized integer and floating-point types (poly_int and poly_float) along with a...