Chris@305
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@305
|
2
|
Chris@305
|
3 /*
|
Chris@305
|
4 Sonic Visualiser
|
Chris@305
|
5 An audio file viewer and annotation editor.
|
Chris@305
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@305
|
7 This file copyright 2006 Chris Cannam, 2006-2014 QMUL.
|
Chris@305
|
8
|
Chris@305
|
9 This program is free software; you can redistribute it and/or
|
Chris@305
|
10 modify it under the terms of the GNU General Public License as
|
Chris@305
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@305
|
12 License, or (at your option) any later version. See the file
|
Chris@305
|
13 COPYING included with this distribution for more information.
|
Chris@305
|
14 */
|
Chris@305
|
15
|
Chris@305
|
16 #ifndef _CLIP_MIXER_H_
|
Chris@305
|
17 #define _CLIP_MIXER_H_
|
Chris@305
|
18
|
Chris@305
|
19 #include <QString>
|
Chris@305
|
20 #include <vector>
|
Chris@305
|
21
|
Chris@305
|
22 /**
|
Chris@305
|
23 * Mix in synthetic notes produced by resampling a prerecorded
|
Chris@305
|
24 * clip. That is, this is a sampler.
|
Chris@305
|
25 */
|
Chris@305
|
26
|
Chris@305
|
27 class ClipMixer
|
Chris@305
|
28 {
|
Chris@305
|
29 public:
|
Chris@305
|
30 ClipMixer(int channels, int sampleRate, int blockSize);
|
Chris@305
|
31 ~ClipMixer();
|
Chris@305
|
32
|
Chris@305
|
33 bool loadClipData(QString clipFilePath, float clipF0);
|
Chris@305
|
34
|
Chris@305
|
35 //!!! what can we find in common with the NoteData type and
|
Chris@305
|
36 //!!! AudioGenerator's NoteOff?
|
Chris@305
|
37
|
Chris@305
|
38 struct NoteStart {
|
Chris@305
|
39 int id; // unique to match note end
|
Chris@305
|
40 int frameOffset; // in current processing block
|
Chris@305
|
41 float frequency; // Hz
|
Chris@305
|
42 float level; // volume in range (0,1]
|
Chris@305
|
43 float pan; // range [-1,1]
|
Chris@305
|
44 };
|
Chris@305
|
45
|
Chris@305
|
46 struct NoteEnd {
|
Chris@305
|
47 int id; // matching note start
|
Chris@305
|
48 int frameOffset; // in current processing block
|
Chris@305
|
49 };
|
Chris@305
|
50
|
Chris@305
|
51 void mix(float **toBuffers,
|
Chris@305
|
52 std::vector<NoteStart> newNotes,
|
Chris@305
|
53 std::vector<NoteEnd> endingNotes);
|
Chris@305
|
54
|
Chris@305
|
55 private:
|
Chris@305
|
56 int m_channels;
|
Chris@305
|
57 int m_sampleRate;
|
Chris@305
|
58 int m_blockSize;
|
Chris@305
|
59
|
Chris@305
|
60 QString m_clipPath;
|
Chris@305
|
61
|
Chris@305
|
62 float *m_clipData;
|
Chris@305
|
63 int m_clipLength;
|
Chris@305
|
64 float m_clipF0;
|
Chris@305
|
65 float m_clipRate;
|
Chris@305
|
66 };
|
Chris@305
|
67
|
Chris@305
|
68
|
Chris@305
|
69 #endif
|