annotate plugin/plugins/SamplePlayer.h @ 27:070e9e1e40ea

* Change SpectrogramLayer to use its own cache type instead of a QImage * Some gcc-4.0 compile fixes
author Chris Cannam
date Tue, 14 Feb 2006 17:43:14 +0000
parents d86891498eef
children 39ae3dee27b9
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 A waveform viewer and audio annotation editor.
Chris@2 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@0 6
Chris@0 7 This is experimental software. Not for distribution.
Chris@0 8 */
Chris@0 9
Chris@0 10 #ifndef _SAMPLE_PLAYER_H_
Chris@0 11 #define _SAMPLE_PLAYER_H_
Chris@0 12
Chris@0 13 #define DSSI_API_LEVEL 2
Chris@0 14
Chris@0 15 #include <ladspa.h>
Chris@0 16 #include <dssi.h>
Chris@0 17 #include <seq_event.h>
Chris@0 18
Chris@0 19 #include <QMutex>
Chris@0 20 #include <QString>
Chris@0 21 #include <vector>
Chris@0 22
Chris@0 23 class SamplePlayer
Chris@0 24 {
Chris@0 25 public:
Chris@0 26 static const DSSI_Descriptor *getDescriptor(unsigned long index);
Chris@0 27
Chris@0 28 private:
Chris@0 29 SamplePlayer(int sampleRate);
Chris@0 30 ~SamplePlayer();
Chris@0 31
Chris@0 32 enum {
Chris@0 33 OutputPort = 0,
Chris@0 34 RetunePort = 1,
Chris@0 35 BasePitchPort = 2,
Chris@0 36 SustainPort = 3,
Chris@0 37 ReleasePort = 4,
Chris@0 38 PortCount = 5
Chris@0 39 };
Chris@0 40
Chris@0 41 enum {
Chris@0 42 Polyphony = 128
Chris@0 43 };
Chris@0 44
Chris@0 45 static const char *const portNames[PortCount];
Chris@0 46 static const LADSPA_PortDescriptor ports[PortCount];
Chris@0 47 static const LADSPA_PortRangeHint hints[PortCount];
Chris@0 48 static const LADSPA_Properties properties;
Chris@0 49 static const LADSPA_Descriptor ladspaDescriptor;
Chris@0 50 static const DSSI_Descriptor dssiDescriptor;
Chris@0 51 static const DSSI_Host_Descriptor *hostDescriptor;
Chris@0 52
Chris@0 53 static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
Chris@0 54 static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
Chris@0 55 static void activate(LADSPA_Handle);
Chris@0 56 static void run(LADSPA_Handle, unsigned long);
Chris@0 57 static void deactivate(LADSPA_Handle);
Chris@0 58 static void cleanup(LADSPA_Handle);
Chris@0 59 static const DSSI_Program_Descriptor *getProgram(LADSPA_Handle, unsigned long);
Chris@0 60 static void selectProgram(LADSPA_Handle, unsigned long, unsigned long);
Chris@0 61 static int getMidiController(LADSPA_Handle, unsigned long);
Chris@0 62 static void runSynth(LADSPA_Handle, unsigned long,
Chris@0 63 snd_seq_event_t *, unsigned long);
Chris@0 64 static void receiveHostDescriptor(const DSSI_Host_Descriptor *descriptor);
Chris@0 65 static void workThreadCallback(LADSPA_Handle);
Chris@0 66
Chris@0 67 void searchSamples();
Chris@0 68 void loadSampleData(QString path);
Chris@0 69 void runImpl(unsigned long, snd_seq_event_t *, unsigned long);
Chris@0 70 void addSample(int, unsigned long, unsigned long);
Chris@0 71
Chris@0 72 float *m_output;
Chris@0 73 float *m_retune;
Chris@0 74 float *m_basePitch;
Chris@0 75 float *m_sustain;
Chris@0 76 float *m_release;
Chris@0 77
Chris@0 78 float *m_sampleData;
Chris@0 79 size_t m_sampleCount;
Chris@0 80 int m_sampleRate;
Chris@0 81
Chris@0 82 long m_ons[Polyphony];
Chris@0 83 long m_offs[Polyphony];
Chris@0 84 int m_velocities[Polyphony];
Chris@0 85 long m_sampleNo;
Chris@0 86
Chris@0 87 QString m_program;
Chris@0 88 std::vector<std::pair<QString, QString> > m_samples; // program name, path
Chris@0 89 bool m_sampleSearchComplete;
Chris@0 90 int m_pendingProgramChange;
Chris@0 91
Chris@0 92 QMutex m_mutex;
Chris@0 93 };
Chris@0 94
Chris@0 95
Chris@0 96 #endif