lmms
Cross-platform music production software
Toggle main menu visibility
Loading...
Searching...
No Matches
include
OscillatorConstants.h
Go to the documentation of this file.
1
/*
2
* OscillatorConstants.h - declaration of constants used in Oscillator and SampleBuffer
3
* for band limited wave tables
4
*
5
* Copyright (c) 2018 Dave French <dave/dot/french3/at/googlemail/dot/com>
6
*
7
* This file is part of LMMS - https://lmms.io
8
*
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public
11
* License as published by the Free Software Foundation; either
12
* version 2 of the License, or (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public
20
* License along with this program (see COPYING); if not, write to the
21
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
* Boston, MA 02110-1301 USA.
23
*
24
*/
25
26
#ifndef LMMS_OSCILLATORCONSTANTS_H
27
#define LMMS_OSCILLATORCONSTANTS_H
28
29
#include <array>
30
31
#include "
LmmsTypes.h
"
32
33
namespace
lmms::OscillatorConstants
34
{
35
36
// Limit wavetables to the audible audio spectrum
37
const
int
MAX_FREQ
= 20000;
38
// Minimum size of table to have all audible bands for midi note 1 (i.e. 20 000 Hz / 8.176 Hz)
39
constexpr
int
WAVETABLE_LENGTH
=
static_cast<
int
>
(
MAX_FREQ
/ 8.176);
40
41
//SEMITONES_PER_TABLE, the smaller the value the smoother the harmonics change on frequency sweeps
42
// with the trade off of increased memory requirements to store the wave tables
43
// require memory = NumberOfWaveShapes*WAVETABLE_LENGTH*(MidiNoteCount/SEMITONES_PER_TABLE)*BytePerSample_t
44
// 7*2446*(128/1)*4 = 8766464 bytes
45
const
int
SEMITONES_PER_TABLE
= 1;
46
const
int
WAVE_TABLES_PER_WAVEFORM_COUNT
= 128 /
SEMITONES_PER_TABLE
;
47
48
// There is some ambiguity around the use of "wavetable", "wavetable synthesis" or related terms.
49
// The following meanings and definitions were selected for use in the Oscillator class:
50
// - wave shape: abstract and precise definition of the graph associated with a given type of wave;
51
// - waveform: digital representations the wave shape, a set of waves optimized for use at varying pitches;
52
// - wavetable: a table containing one period of a wave, with frequency content optimized for a specific pitch.
53
using
wavetable_t
= std::array<sample_t, WAVETABLE_LENGTH>;
54
using
waveform_t
= std::array<wavetable_t, WAVE_TABLES_PER_WAVEFORM_COUNT>;
55
56
}
// namespace lmms::OscillatorConstants
57
58
#endif
// LMMS_OSCILLATORCONSTANTS_H
LmmsTypes.h
lmms::OscillatorConstants
Definition
OscillatorConstants.h:34
lmms::OscillatorConstants::SEMITONES_PER_TABLE
const int SEMITONES_PER_TABLE
Definition
OscillatorConstants.h:45
lmms::OscillatorConstants::WAVETABLE_LENGTH
constexpr int WAVETABLE_LENGTH
Definition
OscillatorConstants.h:39
lmms::OscillatorConstants::waveform_t
std::array< wavetable_t, WAVE_TABLES_PER_WAVEFORM_COUNT > waveform_t
Definition
OscillatorConstants.h:54
lmms::OscillatorConstants::MAX_FREQ
const int MAX_FREQ
Definition
OscillatorConstants.h:37
lmms::OscillatorConstants::wavetable_t
std::array< sample_t, WAVETABLE_LENGTH > wavetable_t
Definition
OscillatorConstants.h:53
lmms::OscillatorConstants::WAVE_TABLES_PER_WAVEFORM_COUNT
const int WAVE_TABLES_PER_WAVEFORM_COUNT
Definition
OscillatorConstants.h:46
Generated on
for lmms by
1.18.0