/usr/include/CLAM/AudioSource.hxx is in libclam-dev 1.4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | #ifndef AudioSource_hxx
#define AudioSource_hxx
#include "Processing.hxx"
#include "AudioOutPort.hxx"
#include <sstream>
namespace CLAM
{
class AudioSource : public Processing
{
public:
struct Port
{
const float* mFloatBuffer;
const double* mDoubleBuffer;
unsigned mBufferSize;
AudioOutPort* mPort;
Port()
: mFloatBuffer(0), mDoubleBuffer(0), mBufferSize(0), mPort(0)
{
}
explicit Port(AudioOutPort* p)
: mFloatBuffer(0), mDoubleBuffer(0), mBufferSize(0), mPort(p)
{
}
};
typedef std::vector<Port> Ports;
private:
class Config : public ProcessingConfig
{
DYNAMIC_TYPE_USING_INTERFACE( Config, 1, ProcessingConfig );
DYN_ATTRIBUTE( 0, public, int, NSources);
~Config();
protected:
void DefaultInit()
{
AddAll();
UpdateData();
SetNSources(1);
};
void LoadFrom(Storage & storage)
{
ProcessingConfig::LoadFrom(storage);
if (not HasNSources())
{
AddNSources();
UpdateData();
SetNSources(1);
}
}
};
private:
Config _config;
Ports _ports;
public:
AudioSource(const ProcessingConfig & config=Config())
{
//After being dropped it is ready to run as it does not need any configuration at all
//SetExecState(Ready);
Configure( config );
// default constructed with 1 port
ResizePorts(1);
}
~AudioSource()
{
for (unsigned port = 0; port < _ports.size(); ++port)
delete _ports[port].mPort;
}
void SetFrameAndHopSize(const int val, unsigned index)
{
CLAM_ASSERT(index < _ports.size(), "AudioOutPort index out of range");
Port& port = _ports[index];
port.mPort->SetSize(val);
port.mPort->SetHop(val);
}
void SetExternalBuffer(const float* buf, unsigned nframes, unsigned index);
void SetExternalBuffer(const double* buf, unsigned nframes, unsigned index);
bool Do();
const char* GetClassName() const { return "AudioSource";}
const ProcessingConfig & GetConfig() const
{
return _config;
}
bool ConcreteConfigure(const ProcessingConfig& config)
{
CopyAsConcreteConfig(_config, config);
unsigned sources = _config.GetNSources();
ResizePorts(sources);
return true;
}
Ports& GetPorts() { return _ports; }
const Ports & GetPorts() const { return _ports; }
private:
std::string const Portname(unsigned port) const
{
std::ostringstream os;
os << port + 1; //to make ports one based (when viewed in jack)
return os.str();
}
void ResizePorts(unsigned sources)
{
if (sources == _ports.size())
return;
for (unsigned port = sources; port < _ports.size(); ++port)
delete _ports[port].mPort;
unsigned oldSize = _ports.size();
_ports.resize(sources);
for (unsigned port = oldSize; port < sources; ++port)
_ports[port] = Port(new AudioOutPort(Portname(port), this));
}
};
} //namespace CLAM
#endif
|