SamplePlayer.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _SAMPLE_PLAYER_H_
00017 #define _SAMPLE_PLAYER_H_
00018 
00019 #define DSSI_API_LEVEL 2
00020 
00021 #include <ladspa.h>
00022 #include <dssi.h>
00023 #include <seq_event.h>
00024 
00025 #include <QMutex>
00026 #include <QString>
00027 #include <vector>
00028 
00029 class SamplePlayer
00030 {
00031 public:
00032     static const DSSI_Descriptor *getDescriptor(unsigned long index);
00033 
00034 private:
00035     SamplePlayer(int sampleRate);
00036     ~SamplePlayer();
00037 
00038     enum {
00039         OutputPort    = 0,
00040         RetunePort    = 1,
00041         BasePitchPort = 2,
00042         ConcertAPort  = 3,
00043         SustainPort   = 4,
00044         ReleasePort   = 5,
00045         PortCount     = 6
00046     };
00047 
00048     enum {
00049         Polyphony = 128
00050     };
00051 
00052     static const char *const portNames[PortCount];
00053     static const LADSPA_PortDescriptor ports[PortCount];
00054     static const LADSPA_PortRangeHint hints[PortCount];
00055     static const LADSPA_Properties properties;
00056     static const LADSPA_Descriptor ladspaDescriptor;
00057     static const DSSI_Descriptor dssiDescriptor;
00058     static const DSSI_Host_Descriptor *hostDescriptor;
00059 
00060     static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
00061     static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
00062     static void activate(LADSPA_Handle);
00063     static void run(LADSPA_Handle, unsigned long);
00064     static void deactivate(LADSPA_Handle);
00065     static void cleanup(LADSPA_Handle);
00066     static char *configure(LADSPA_Handle, const char *, const char *);
00067     static const DSSI_Program_Descriptor *getProgram(LADSPA_Handle, unsigned long);
00068     static void selectProgram(LADSPA_Handle, unsigned long, unsigned long);
00069     static int getMidiController(LADSPA_Handle, unsigned long);
00070     static void runSynth(LADSPA_Handle, unsigned long,
00071                          snd_seq_event_t *, unsigned long);
00072     static void receiveHostDescriptor(const DSSI_Host_Descriptor *descriptor);
00073     static void workThreadCallback(LADSPA_Handle);
00074 
00075     void searchSamples();
00076     void loadSampleData(QString path);
00077     void runImpl(unsigned long, snd_seq_event_t *, unsigned long);
00078     void addSample(int, unsigned long, unsigned long);
00079 
00080     float *m_output;
00081     float *m_retune;
00082     float *m_basePitch;
00083     float *m_concertA;
00084     float *m_sustain;
00085     float *m_release;
00086 
00087     float *m_sampleData;
00088     size_t m_sampleCount;
00089     int m_sampleRate;
00090 
00091     long m_ons[Polyphony];
00092     long m_offs[Polyphony];
00093     int m_velocities[Polyphony];
00094     long m_sampleNo;
00095 
00096     QString m_sampleDir;
00097     QString m_program;
00098     std::vector<std::pair<QString, QString> > m_samples; // program name, path
00099     bool m_sampleSearchComplete;
00100     int m_pendingProgramChange;
00101 
00102     QMutex m_mutex;
00103 };
00104 
00105 
00106 #endif

Generated on Wed Feb 20 15:45:28 2008 for SonicVisualiser by  doxygen 1.5.1