Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
scale.h
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 // Scale
22 //=============================================================================
23 
24 #ifndef SCALE_H
25 #define SCALE_H
26 
27 #include <QVector>
28 #include <QIODevice>
29 
30 #include "wave.h"
31 
32 class Voice;
33 
45 
46 class Scale
47 {
48 public:
49 
50  Scale();
51 
52  Wave &getWave(int &key);
53 
54  bool write (QIODevice &iodevice, Voice* voice = nullptr);
55  bool read (QIODevice &iodevice, Voice* voice = nullptr);
56 
57  void printInfo();
58 
59  void generateArtificialSound (Voice* voice = nullptr, int samplerate = 44100);
60 
61  void cancel() { mCancellationRequested = true; }
62 
63  bool insert (const int key,
64  const QVector<qint32> &L, const QVector<qint32> &R,
65  const bool release, const double amplification);
66 
67 
68 
69 private:
70 
71  QVector<Wave> mWaves;
72  static constexpr int N = 128;
73  const int ctag = 0x78563412;
75 };
76 
77 #endif // SCALE_H
Wave & getWave(int &key)
Get the wave corresponding to a given key.
Definition: scale.cpp:57
Class holding the sampled sound for one key.
Definition: wave.h:49
static constexpr int N
Maximal number of waves in a scale.
Definition: scale.h:72
Voice - a set of scales, keeping the acoustic data of an instrument.
Definition: voice.h:39
Scale - a set of PCM waves with a characteristic intensity and length.
Definition: scale.h:46
bool read(QIODevice &iodevice, Voice *voice=nullptr)
Read data of a scale from a device.
Definition: scale.cpp:176
Scale()
Constructor, creates N=128 empty wave objects.
Definition: scale.cpp:44
const int ctag
Tag to recognize a scale in a file.
Definition: scale.h:73
bool write(QIODevice &iodevice, Voice *voice=nullptr)
Write scale to device.
Definition: scale.cpp:145
void printInfo()
Scale::printInfo.
Definition: scale.cpp:207
void generateArtificialSound(Voice *voice=nullptr, int samplerate=44100)
Generate a scale of artificial sounds in equal temperament.
Definition: scale.cpp:70
bool insert(const int key, const QVector< qint32 > &L, const QVector< qint32 > &R, const bool release, const double amplification)
Insert a newly recorded or generated waveform into the scale. This function checks the parameters and...
Definition: scale.cpp:103
void cancel()
Definition: scale.h:61
bool mCancellationRequested
Cancel loading.
Definition: scale.h:74
QVector< Wave > mWaves
This is the actual vector of waves.
Definition: scale.h:71