CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

SndFileInstrument.h
Go to the documentation of this file.
1 ///
2 /// SndFileInstrument.h -- Sound file player instrument class
3 /// See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 ///
5 /// This instrument implements sound file playback with a basic
6 /// A/R envelope and panning; it provides 4 parameter accessors
7 /// for use by OSC.
8 ///
9 /// Accessors
10 /// "am", set_amplitude_f
11 /// "ra", set_rate_f
12 /// "po", set_position_f
13 /// "fi", set_file_f
14 /// "st", set_start_f
15 /// "en", set_stop_f
16 /// "at", set_attack_f
17 /// "de", set_decay_f
18 ///
19 /// OSC note formats (6 or 14 arguments):
20 /// ampl, pos
21 /// ampl, pos, rate
22 /// ampl, pos, start, stop
23 /// ampl, pos, rate, start, stop
24 /// ampl, pos, start, stop, attack, decay
25 /// ampl, pos, rate, start, stop, attack, decay
26
27 #ifndef CSL_SndFile_Instrument_H
28 #define CSL_SndFile_Instrument_H
29
30 #include "Instrument.h"
31 #include "SoundFileL.h"
32
33 namespace csl {
34
35 ///
36 /// Sound file player instrument
37 ///
38
39 class SndFileInstrument : public Instrument {
40 public:
41 SndFileInstrument(string path, int start = -1, int stop = -1);
42 SndFileInstrument(string folder, string path, int start = -1, int stop = -1);
43 ~SndFileInstrument();
44
45 /// Plug functions
46 void setParameter(unsigned selector, int argc, void **argv, const char *types);
47 /// play note
48 void play();
49 void playOSC(int argc, void **argv, const char *types);
50 void playNote(float ampl = 1, float rate = 1, float pos = 0, int start = -1, int stop = -1,
51 float attack = 0.0, float decay = 0.0);
52 void playMIDI(int chan, int key, int vel);
53
54 ///< These are the UGens of the DSP graph (i.e., the sndfile player instrument)
55 LSoundFile mPlayer; ///< sample player
56 AR mEnvelope; ///< AR envelope
57 Panner mPanner; ///< stereo panner
58 StaticVariable mRate; ///< plugs playback rate (ignored for now)
59 int mStart, mStop; ///< start/stop sample indices
60 protected:
61 void initialize(string path);
62
63 };
64
65 //class SampleFile : public SoundFile {
66 // SampleFile(); /// Constructor
67 // SampleFile(string path, unsigned MIDIKey, double frequency, double minRatio, double maxRatio);
68 // ~SampleFile();
69 // /// Data members
70 // unsigned mMIDIKey; // sample's MIDI key #
71 // double mFrequency; // sample's actual frequency
72 // double mMinRatio; // min transp.
73 // double mMaxRatio; // max transp. (often 1.0)
74 //
75 // double ratioForKey(int desiredMIDI); // answer rate ratios for the given MIDI or Hz transpositions
76 // double ratioForPitch(int desiredMIDI);
77
78 ///
79 /// Sample bank player instrument
80 ///
81
82 class SampleBankInstrument : public SndFileInstrument {
83 public:
84 SampleBankInstrument();
85 ~SampleBankInstrument();
86
87 void addSample(LSoundFile & sndFile, unsigned midi = 0, double freq = 0.0, double minRatio = 0.75);
88
89 void play();
90 void playOSC(int argc, void **argv, const char *types);
91 void playNote(float ampl = 1, float rate = 1, float pos = 0, int start = -1, int stop = -1,
92 float attack = 0.0, float decay = 0.0);
93
94 protected:
95 // SampleBank mBank; ///< sample bank map
96
97 };
98
99 }
100
101 #endif