annotate plugin/plugins/SamplePlayer.h @ 77:2beca8ddcdc3

* Add BZipFileDevice to handle bzip2 compress/uncompress without all that ugly code in MainWindow.cpp * Remove all that ugly code in MainWindow.cpp and replace with uses of BZipFileDevice * Fix layer import/export for SV XML layers * and a few other minor fixes
author Chris Cannam
date Wed, 12 Apr 2006 09:59:40 +0000
parents 163f3428bbe0
children b2067aff8cd6
rev   line source
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@0 21 #include <ladspa.h>
Chris@0 22 #include <dssi.h>
Chris@0 23 #include <seq_event.h>
Chris@0 24
Chris@0 25 #include <QMutex>
Chris@0 26 #include <QString>
Chris@0 27 #include <vector>
Chris@0 28
Chris@0 29 class SamplePlayer
Chris@0 30 {
Chris@0 31 public:
Chris@0 32 static const DSSI_Descriptor *getDescriptor(unsigned long index);
Chris@0 33
Chris@0 34 private:
Chris@0 35 SamplePlayer(int sampleRate);
Chris@0 36 ~SamplePlayer();
Chris@0 37
Chris@0 38 enum {
Chris@0 39 OutputPort = 0,
Chris@0 40 RetunePort = 1,
Chris@0 41 BasePitchPort = 2,
Chris@0 42 SustainPort = 3,
Chris@0 43 ReleasePort = 4,
Chris@0 44 PortCount = 5
Chris@0 45 };
Chris@0 46
Chris@0 47 enum {
Chris@0 48 Polyphony = 128
Chris@0 49 };
Chris@0 50
Chris@0 51 static const char *const portNames[PortCount];
Chris@0 52 static const LADSPA_PortDescriptor ports[PortCount];
Chris@0 53 static const LADSPA_PortRangeHint hints[PortCount];
Chris@0 54 static const LADSPA_Properties properties;
Chris@0 55 static const LADSPA_Descriptor ladspaDescriptor;
Chris@0 56 static const DSSI_Descriptor dssiDescriptor;
Chris@0 57 static const DSSI_Host_Descriptor *hostDescriptor;
Chris@0 58
Chris@0 59 static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
Chris@0 60 static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
Chris@0 61 static void activate(LADSPA_Handle);
Chris@0 62 static void run(LADSPA_Handle, unsigned long);
Chris@0 63 static void deactivate(LADSPA_Handle);
Chris@0 64 static void cleanup(LADSPA_Handle);
Chris@75 65 static char *configure(LADSPA_Handle, const char *, const char *);
Chris@0 66 static const DSSI_Program_Descriptor *getProgram(LADSPA_Handle, unsigned long);
Chris@0 67 static void selectProgram(LADSPA_Handle, unsigned long, unsigned long);
Chris@0 68 static int getMidiController(LADSPA_Handle, unsigned long);
Chris@0 69 static void runSynth(LADSPA_Handle, unsigned long,
Chris@0 70 snd_seq_event_t *, unsigned long);
Chris@0 71 static void receiveHostDescriptor(const DSSI_Host_Descriptor *descriptor);
Chris@0 72 static void workThreadCallback(LADSPA_Handle);
Chris@0 73
Chris@0 74 void searchSamples();
Chris@0 75 void loadSampleData(QString path);
Chris@0 76 void runImpl(unsigned long, snd_seq_event_t *, unsigned long);
Chris@0 77 void addSample(int, unsigned long, unsigned long);
Chris@0 78
Chris@0 79 float *m_output;
Chris@0 80 float *m_retune;
Chris@0 81 float *m_basePitch;
Chris@0 82 float *m_sustain;
Chris@0 83 float *m_release;
Chris@0 84
Chris@0 85 float *m_sampleData;
Chris@0 86 size_t m_sampleCount;
Chris@0 87 int m_sampleRate;
Chris@0 88
Chris@0 89 long m_ons[Polyphony];
Chris@0 90 long m_offs[Polyphony];
Chris@0 91 int m_velocities[Polyphony];
Chris@0 92 long m_sampleNo;
Chris@0 93
Chris@75 94 QString m_samplePath;
Chris@0 95 QString m_program;
Chris@0 96 std::vector<std::pair<QString, QString> > m_samples; // program name, path
Chris@0 97 bool m_sampleSearchComplete;
Chris@0 98 int m_pendingProgramChange;
Chris@0 99
Chris@0 100 QMutex m_mutex;
Chris@0 101 };
Chris@0 102
Chris@0 103
Chris@0 104 #endif