CSL  6.0
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 "SoundFile.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);
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  SoundFile 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 
83 public:
86 
87  void addSample(SoundFile & 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
StaticVariable mRate
plugs playback rate (ignored for now)
void playNote(float ampl=1, float rate=1, float pos=0, int start=-1, int stop=-1, float attack=0.0, float decay=0.0)
Sample bank player instrument.
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
void playMIDI(int chan, int key, int vel)
These are the UGens of the DSP graph (i.e., the sndfile player instrument)
int mStop
start/stop sample indices
StaticVariable – he static external variable (plug) class. This is a kind of variable that holds ont...
Definition: Variable.h:50
SndFileInstrument(string path, int start=-1, int stop=-1)
Panner mPanner
stereo panner
void playNote(float ampl=1, float rate=1, float pos=0, int start=-1, int stop=-1, float attack=0.0, float decay=0.0)
void addSample(SoundFile &sndFile, unsigned midi=0, double freq=0.0, double minRatio=0.75)
void setParameter(unsigned selector, int argc, void **argv, const char *types)
Plug functions.
SoundFile mPlayer
sample player
Instrument class (abstract)
Definition: Instrument.h:56
void initialize(string path)
void playOSC(int argc, void **argv, const char *types)
Sound file player instrument.
AR = 3-segment attack/release envelope class.
Definition: Envelope.h:199
The CSL mono-to-stereo L/R panner class.
Definition: Mixer.h:66
void play()
play note
AR mEnvelope
AR envelope.
void playOSC(int argc, void **argv, const char *types)