Chris@49
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@52
|
4 Sonic Visualiser
|
Chris@52
|
5 An audio file viewer and annotation editor.
|
Chris@52
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@52
|
7 This file copyright 2006 Chris Cannam.
|
Chris@0
|
8
|
Chris@52
|
9 This program is free software; you can redistribute it and/or
|
Chris@52
|
10 modify it under the terms of the GNU General Public License as
|
Chris@52
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@52
|
12 License, or (at your option) any later version. See the file
|
Chris@52
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #ifndef _SAMPLE_PLAYER_H_
|
Chris@0
|
17 #define _SAMPLE_PLAYER_H_
|
Chris@0
|
18
|
Chris@0
|
19 #define DSSI_API_LEVEL 2
|
Chris@0
|
20
|
Chris@646
|
21 #include "../api/ladspa.h"
|
Chris@646
|
22 #include "../api/dssi.h"
|
Chris@646
|
23
|
Chris@0
|
24 #include <seq_event.h>
|
Chris@0
|
25
|
Chris@0
|
26 #include <QMutex>
|
Chris@0
|
27 #include <QString>
|
Chris@0
|
28 #include <vector>
|
Chris@0
|
29
|
Chris@0
|
30 class SamplePlayer
|
Chris@0
|
31 {
|
Chris@0
|
32 public:
|
Chris@0
|
33 static const DSSI_Descriptor *getDescriptor(unsigned long index);
|
Chris@0
|
34
|
Chris@0
|
35 private:
|
Chris@0
|
36 SamplePlayer(int sampleRate);
|
Chris@0
|
37 ~SamplePlayer();
|
Chris@0
|
38
|
Chris@0
|
39 enum {
|
Chris@0
|
40 OutputPort = 0,
|
Chris@0
|
41 RetunePort = 1,
|
Chris@0
|
42 BasePitchPort = 2,
|
Chris@143
|
43 ConcertAPort = 3,
|
Chris@143
|
44 SustainPort = 4,
|
Chris@143
|
45 ReleasePort = 5,
|
Chris@143
|
46 PortCount = 6
|
Chris@0
|
47 };
|
Chris@0
|
48
|
Chris@0
|
49 enum {
|
Chris@0
|
50 Polyphony = 128
|
Chris@0
|
51 };
|
Chris@0
|
52
|
Chris@0
|
53 static const char *const portNames[PortCount];
|
Chris@0
|
54 static const LADSPA_PortDescriptor ports[PortCount];
|
Chris@0
|
55 static const LADSPA_PortRangeHint hints[PortCount];
|
Chris@0
|
56 static const LADSPA_Properties properties;
|
Chris@0
|
57 static const LADSPA_Descriptor ladspaDescriptor;
|
Chris@0
|
58 static const DSSI_Descriptor dssiDescriptor;
|
Chris@0
|
59 static const DSSI_Host_Descriptor *hostDescriptor;
|
Chris@0
|
60
|
Chris@0
|
61 static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
|
Chris@0
|
62 static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
|
Chris@0
|
63 static void activate(LADSPA_Handle);
|
Chris@0
|
64 static void run(LADSPA_Handle, unsigned long);
|
Chris@0
|
65 static void deactivate(LADSPA_Handle);
|
Chris@0
|
66 static void cleanup(LADSPA_Handle);
|
Chris@75
|
67 static char *configure(LADSPA_Handle, const char *, const char *);
|
Chris@0
|
68 static const DSSI_Program_Descriptor *getProgram(LADSPA_Handle, unsigned long);
|
Chris@0
|
69 static void selectProgram(LADSPA_Handle, unsigned long, unsigned long);
|
Chris@0
|
70 static int getMidiController(LADSPA_Handle, unsigned long);
|
Chris@0
|
71 static void runSynth(LADSPA_Handle, unsigned long,
|
Chris@0
|
72 snd_seq_event_t *, unsigned long);
|
Chris@0
|
73 static void receiveHostDescriptor(const DSSI_Host_Descriptor *descriptor);
|
Chris@0
|
74 static void workThreadCallback(LADSPA_Handle);
|
Chris@0
|
75
|
Chris@0
|
76 void searchSamples();
|
Chris@0
|
77 void loadSampleData(QString path);
|
Chris@0
|
78 void runImpl(unsigned long, snd_seq_event_t *, unsigned long);
|
Chris@0
|
79 void addSample(int, unsigned long, unsigned long);
|
Chris@0
|
80
|
Chris@0
|
81 float *m_output;
|
Chris@0
|
82 float *m_retune;
|
Chris@0
|
83 float *m_basePitch;
|
Chris@143
|
84 float *m_concertA;
|
Chris@0
|
85 float *m_sustain;
|
Chris@0
|
86 float *m_release;
|
Chris@0
|
87
|
Chris@0
|
88 float *m_sampleData;
|
Chris@0
|
89 size_t m_sampleCount;
|
Chris@0
|
90 int m_sampleRate;
|
Chris@0
|
91
|
Chris@0
|
92 long m_ons[Polyphony];
|
Chris@0
|
93 long m_offs[Polyphony];
|
Chris@0
|
94 int m_velocities[Polyphony];
|
Chris@0
|
95 long m_sampleNo;
|
Chris@0
|
96
|
Chris@83
|
97 QString m_sampleDir;
|
Chris@0
|
98 QString m_program;
|
Chris@0
|
99 std::vector<std::pair<QString, QString> > m_samples; // program name, path
|
Chris@0
|
100 bool m_sampleSearchComplete;
|
Chris@0
|
101 int m_pendingProgramChange;
|
Chris@0
|
102
|
Chris@0
|
103 QMutex m_mutex;
|
Chris@0
|
104 };
|
Chris@0
|
105
|
Chris@0
|
106
|
Chris@0
|
107 #endif
|