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