Nsound  0.9.4
AudioBackend.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: AudioBackend.h 874 2014-09-08 02:21:29Z weegreenblobbie $
4 //
5 // Nsound is a C++ library and Python module for audio synthesis featuring
6 // dynamic digital filters. Nsound lets you easily shape waveforms and write
7 // to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8 // use.
9 //
10 // Copyright (c) 2011-Present Nick Hilton
11 //
12 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
13 //
14 //-----------------------------------------------------------------------------
15 
16 //-----------------------------------------------------------------------------
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU Library General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 //
32 //-----------------------------------------------------------------------------
33 #ifndef _NSOUND_AUDIO_BACKEND_H_
34 #define _NSOUND_AUDIO_BACKEND_H_
35 
36 #include <Nsound/Nsound.h>
38 
39 #include <string>
40 
41 namespace Nsound
42 {
43 
44 class AudioPlayback;
45 class AudioStream;
46 
47 //-----------------------------------------------------------------------------
49 {
50  public:
51 
52  enum State
53  {
57  };
58 
60  uint32 sample_rate = 44100,
61  uint32 channels = 1,
62  uint32 bits_per_sample = 16)
63  :
64  sample_rate_(sample_rate),
65  channels_(channels),
66  bits_per_sample_(bits_per_sample),
68 
69  virtual
71 
72  virtual
74  getBackendType() = 0;
75 
76  uint32
78 
79  uint32
80  getChannels(){return channels_;};
81 
82  virtual
83  std::string
84  getError() = 0;
85 
86  virtual
87  std::string
88  getInfo() = 0;
89 
90  uint32
92 
93  State
94  getState(){return state_;};
95 
97  std::string
99 
101  static
102  std::string
103  getStateString(const AudioBackend::State & state);
104 
105  virtual
106  void
107  initialize() = 0;
108 
109  virtual
110  void
111  play(void * data, uint32 n_bytes) = 0;
112 
113  virtual
114  void
115  scanDevices(AudioPlayback & pb, const AudioStream & test_clip) = 0;
116 
117  virtual
118  void
119  setOption(const std::string & key, const std::string & value) = 0;
120 
121  virtual
122  void
123  shutdown() = 0;
124 
125  protected:
126 
131 };
132 
133 } // namespace Nsound
134 
135 // :mode=c++: jEdit modeline
136 #endif
unsigned int uint32
Definition: Nsound.h:153
virtual void play(void *data, uint32 n_bytes)=0
virtual void scanDevices(AudioPlayback &pb, const AudioStream &test_clip)=0
virtual std::string getInfo()=0
virtual void setOption(const std::string &key, const std::string &value)=0
AudioBackend(uint32 sample_rate=44100, uint32 channels=1, uint32 bits_per_sample=16)
Definition: AudioBackend.h:59
virtual AudioBackendType getBackendType()=0
virtual void shutdown()=0
std::string getStateString()
Returns the backend state.
Definition: AudioBackend.cc:43
virtual std::string getError()=0
virtual ~AudioBackend()
Definition: AudioBackend.h:70
virtual void initialize()=0
uint32 getBitsPerSample()
Definition: AudioBackend.h:77