annotate plugin/plugins/SamplePlayer.h @ 168:04baa690f90d

* Start adding StorageAdviser class to determine whether caches should be on disc or in memory
author Chris Cannam
date Mon, 25 Sep 2006 13:44:05 +0000
parents 0f0c9cf65d5e
children 9a6b50d3cc50
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@143 42 ConcertAPort = 3,
Chris@143 43 SustainPort = 4,
Chris@143 44 ReleasePort = 5,
Chris@143 45 PortCount = 6
Chris@0 46 };
Chris@0 47
Chris@0 48 enum {
Chris@0 49 Polyphony = 128
Chris@0 50 };
Chris@0 51
Chris@0 52 static const char *const portNames[PortCount];
Chris@0 53 static const LADSPA_PortDescriptor ports[PortCount];
Chris@0 54 static const LADSPA_PortRangeHint hints[PortCount];
Chris@0 55 static const LADSPA_Properties properties;
Chris@0 56 static const LADSPA_Descriptor ladspaDescriptor;
Chris@0 57 static const DSSI_Descriptor dssiDescriptor;
Chris@0 58 static const DSSI_Host_Descriptor *hostDescriptor;
Chris@0 59
Chris@0 60 static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
Chris@0 61 static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
Chris@0 62 static void activate(LADSPA_Handle);
Chris@0 63 static void run(LADSPA_Handle, unsigned long);
Chris@0 64 static void deactivate(LADSPA_Handle);
Chris@0 65 static void cleanup(LADSPA_Handle);
Chris@75 66 static char *configure(LADSPA_Handle, const char *, const char *);
Chris@0 67 static const DSSI_Program_Descriptor *getProgram(LADSPA_Handle, unsigned long);
Chris@0 68 static void selectProgram(LADSPA_Handle, unsigned long, unsigned long);
Chris@0 69 static int getMidiController(LADSPA_Handle, unsigned long);
Chris@0 70 static void runSynth(LADSPA_Handle, unsigned long,
Chris@0 71 snd_seq_event_t *, unsigned long);
Chris@0 72 static void receiveHostDescriptor(const DSSI_Host_Descriptor *descriptor);
Chris@0 73 static void workThreadCallback(LADSPA_Handle);
Chris@0 74
Chris@0 75 void searchSamples();
Chris@0 76 void loadSampleData(QString path);
Chris@0 77 void runImpl(unsigned long, snd_seq_event_t *, unsigned long);
Chris@0 78 void addSample(int, unsigned long, unsigned long);
Chris@0 79
Chris@0 80 float *m_output;
Chris@0 81 float *m_retune;
Chris@0 82 float *m_basePitch;
Chris@143 83 float *m_concertA;
Chris@0 84 float *m_sustain;
Chris@0 85 float *m_release;
Chris@0 86
Chris@0 87 float *m_sampleData;
Chris@0 88 size_t m_sampleCount;
Chris@0 89 int m_sampleRate;
Chris@0 90
Chris@0 91 long m_ons[Polyphony];
Chris@0 92 long m_offs[Polyphony];
Chris@0 93 int m_velocities[Polyphony];
Chris@0 94 long m_sampleNo;
Chris@0 95
Chris@83 96 QString m_sampleDir;
Chris@0 97 QString m_program;
Chris@0 98 std::vector<std::pair<QString, QString> > m_samples; // program name, path
Chris@0 99 bool m_sampleSearchComplete;
Chris@0 100 int m_pendingProgramChange;
Chris@0 101
Chris@0 102 QMutex m_mutex;
Chris@0 103 };
Chris@0 104
Chris@0 105
Chris@0 106 #endif