Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
tone.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Tone
22 //=============================================================================
23 
24 #include "tone.h"
25 
26 
27 //-----------------------------------------------------------------------------
28 // Constructor
29 //-----------------------------------------------------------------------------
30 
34 
36  : mState(IDLE)
37  , mKey(0)
38  , mTime(0)
39  , mVolume(0)
40  , left(0)
41  , right(0)
42  , pSample(nullptr)
43  , mType(UNDEFINED)
44  , mScaleIndex(0)
45 {}
46 
47 
48 
49 //-----------------------------------------------------------------------------
50 // Constructor with arguments
51 //-----------------------------------------------------------------------------
52 
62 
63 Tone::Tone(int key, int scaleindex, Wave &sample, double volume, Type type)
64 {
65  mState = PLAYING;
66  mKey = key;
67  mTime = 0;
68  mVolume = volume;
69  left = right = 0;
70  pSample = &sample;
71  mType = type;
72  mScaleIndex = scaleindex;
73 }
int mKey
Key index (Midi) ranging from 0 to 127.
Definition: tone.h:79
Class holding the sampled sound for one key.
Definition: wave.h:49
Tone()
Defautl constructor, resetting the member variables.
Definition: tone.cpp:35
qint16 right
store last PCM values, init to zero
Definition: tone.h:84
quint32 mTime
time in units of 1/4096/SampleRate sec
Definition: tone.h:80
double mVolume
overall volume ranging from 0 to 1
Definition: tone.h:82
int mScaleIndex
Index to the used scale.
Definition: tone.h:88
Type
Definition: tone.h:48
Wave * pSample
Pointer to the wave.
Definition: tone.h:86
qint16 left
Definition: tone.h:84
State mState
Phase in which the tone is playing.
Definition: tone.h:78
Type mType
Type of the wave.
Definition: tone.h:87
Tone is playing in normal mode.
Definition: tone.h:59