/// Return the number of audio samples the device can handle in
/// a write without blocking. This version always returns SIZE_MAX.
- virtual size_t
+ virtual std::size_t
ready();
/// Write audio into the "short" type.
virtual std::size_t
- write16(const int16_t * array, std::size_t length);
+ write16(const std::int16_t * array, std::size_t length);
};
AudioSink::AudioSink(const char * p)
// Write audio into the "short" type.
std::size_t
- AudioSink::write16(const int16_t * array, std::size_t length)
+ AudioSink::write16(const std::int16_t * array, std::size_t length)
{
return length;
}
return new ::FreeDV::AudioSink(parameter);
}
- size_t
+ std::size_t
AudioSink::ready()
{
return SIZE_MAX;
/// Return the amount of bytes ready for read. In this case, it always
/// returns 0.
- size_t ready();
+ std::size_t ready();
};
BlankPanel::BlankPanel(const char * parameter, Interfaces * interfaces)
{
}
- size_t
+ std::size_t
BlankPanel::ready()
{
return 0;
/// \param o The array of audio samples after decoding, in an array
/// of signed 16-bit integers.
/// \param length The number of bytes of data to be decoded.
- /// \return The number of int16_t elements in the decoded array.
+ /// \return The number of std::int16_t elements in the decoded array.
virtual std::size_t
- decode16(const uint8_t * i, int16_t * o, \
+ decode16(const std::uint8_t * i, std::int16_t * o, \
std::size_t length);
/// of signed 16-bit integers.
/// \param o The encoded data, in an array of unsigned 8-bit integers.
/// \param length The number of audio samples to be encoded.
- /// \return The number of uint8_t elements in the encoded array.
+ /// \return The number of std::uint8_t elements in the encoded array.
virtual std::size_t
- encode16(const int16_t * i, uint8_t * o, \
+ encode16(const std::int16_t * i, std::uint8_t * o, \
std::size_t length);
/// Return the duration of a frame in milliseconds.
std::size_t const
CodecNoOp::bytes_per_frame() const
{
- return sizeof(int16_t);
+ return sizeof(std::int16_t);
}
std::size_t
- CodecNoOp::decode16(const uint8_t * i, int16_t * o, std::size_t length)
+ CodecNoOp::decode16(const std::uint8_t * i, std::int16_t * o, std::size_t length)
{
return length;
}
std::size_t
- CodecNoOp::encode16(const int16_t * i, uint8_t * o, std::size_t length)
+ CodecNoOp::encode16(const std::int16_t * i, std::uint8_t * o, std::size_t length)
{
return length;
}
/// or a memory leak will occurr.
char * copy_string(const char * s);
+ /// Simple C++ circular buffer class.
+ /// Written to avoid STL templates, Boost, etc. in order to keep down the
+ /// size of the embedded version of this program.
+ class CircularBuffer {
+ private:
+ char * buffer;
+ std::size_t length;
+ char * in;
+ char * out;
+
+ public:
+ };
+
/// Set the real-time parameters in the scheduler before running our main
/// loop.
void set_scheduler();
/// All drivers present a unidirectional interface.
/// If the underlying device is bidirectional that detail is hidden and
/// we present one or more separate read and write drivers.
- virtual size_t ready() = 0;
+ virtual std::size_t ready() = 0;
virtual ~IODevice() = 0;
};
/// Read audio into an array of the signed 16-bit integer type.
virtual std::size_t
- read16(int16_t * array, std::size_t length) = 0;
+ read16(std::int16_t * array, std::size_t length) = 0;
};
/// Virtual base class for audio output drivers.
/// Write audio from an array of the signed 16-bit integer type.
virtual std::size_t
- write16(const int16_t * array, std::size_t length) = 0;
+ write16(const std::int16_t * array, std::size_t length) = 0;
};
/// Virtual base class for codecs.
/// \param o The array of audio samples after decoding, in an array
/// of signed 16-bit integers.
/// \param length The number of bytes of data to be decoded.
- /// \return The number of int16_t elements in the decoded array.
+ /// \return The number of std::int16_t elements in the decoded array.
virtual std::size_t
- decode16(const uint8_t * i, int16_t * o, \
+ decode16(const std::uint8_t * i, std::int16_t * o, \
std::size_t length) = 0;
/// of signed 16-bit integers.
/// \param o The encoded data, in an array of unsigned 8-bit integers.
/// \param length The number of audio samples to be encoded.
- /// \return The number of uint8_t elements in the encoded array.
+ /// \return The number of std::uint8_t elements in the encoded array.
virtual std::size_t
- encode16(const int16_t * i, uint8_t * o, \
+ encode16(const std::int16_t * i, std::uint8_t * o, \
std::size_t length) = 0;
/// Return the duration of a frame in milliseconds.
virtual void key(bool value) = 0;
/// Return the amount of bytes ready to write.
- virtual size_t ready() = 0;
+ virtual std::size_t ready() = 0;
};
/// Softmodem driver.
/// of signed 16-bit integers.
/// \param o The demodulated data, in an array of unsigned 8-bit integers.
/// \param length The number of audio samples to be demodulated.
- /// \return The number of uint8_t elements in the demodulated array.
+ /// \return The number of std::uint8_t elements in the demodulated array.
virtual std::size_t
- demodulate16(const int16_t * i, uint8_t * o, \
+ demodulate16(const std::int16_t * i, std::uint8_t * o, \
std::size_t length) = 0;
/// Modulate from data to audio samples.
/// \param o The array of audio samples after modulation, in an array
/// of signed 16-bit integers.
/// \param length The number of bytes of data to be modulated.
- /// \return The number of int16_t elements in the modulated array.
+ /// \return The number of std::int16_t elements in the modulated array.
virtual std::size_t
- modulate16(const uint8_t * i, int16_t * o, \
+ modulate16(const std::uint8_t * i, std::int16_t * o, \
std::size_t length) = 0;
/// Return the duration of a frame in milliseconds.
public:
/// Read the text data.
- virtual size_t read(char * buffer, size_t length) = 0;
+ virtual std::size_t read(char * buffer, std::size_t length) = 0;
virtual ~TextInput() = 0;
};
/// Return the amount of bytes ready for read. In this case, it always
/// returns SIZE_MAX.
- size_t ready();
+ std::size_t ready();
};
KeyingSink::KeyingSink(const char * parameters)
std::cerr << "keying: RECEIVE" << std::endl;
}
- size_t
+ std::size_t
KeyingSink::ready()
{
return SIZE_MAX;
/// of signed 16-bit integers.
/// \param o The demodulated data, in an array of unsigned 8-bit integers.
/// \param length The number of audio samples to be demodulated.
- /// \return The number of uint8_t elements in the demodulated array.
+ /// \return The number of std::uint8_t elements in the demodulated array.
virtual std::size_t
- demodulate16(const int16_t * i, uint8_t * o, \
+ demodulate16(const std::int16_t * i, std::uint8_t * o, \
std::size_t length);
/// Modulate from data to audio samples.
/// \param o The array of audio samples after modulation, in an array
/// of signed 16-bit integers.
/// \param length The number of bytes of data to be modulated.
- /// \return The number of int16_t elements in the modulated array.
+ /// \return The number of std::int16_t elements in the modulated array.
virtual std::size_t
- modulate16(const uint8_t * i, int16_t * o, \
+ modulate16(const std::uint8_t * i, std::int16_t * o, \
std::size_t length);
/// Return the duration of a frame in milliseconds.
std::size_t const
ModemNoOp::bytes_per_frame() const
{
- return sizeof(int16_t);
+ return sizeof(std::int16_t);
}
std::size_t
- ModemNoOp::demodulate16(const int16_t * i, uint8_t * o, std::size_t length)
+ ModemNoOp::demodulate16(const std::int16_t * i, std::uint8_t * o, std::size_t length)
{
return length;
}
std::size_t
- ModemNoOp::modulate16(const uint8_t * i, int16_t * o, std::size_t length)
+ ModemNoOp::modulate16(const std::uint8_t * i, std::int16_t * o, std::size_t length)
{
return length;
}
virtual ~PTTConstant();
/// Return the amount of bytes ready for read.
- size_t ready();
+ std::size_t ready();
/// Return true if the PTT input is pressed.
bool state();
{
}
- size_t
+ std::size_t
PTTConstant::ready()
{
if ( ready_one_shot )
static void
receive(Interfaces * i)
{
- const size_t samples_to_decode = i->receiver->ready()
+ const std::size_t samples_to_decode = i->receiver->ready()
% i->modem->samples_per_frame();
}
/// This driver provides constant text.
class TextConstant : public TextInput {
private:
- const size_t length;
- size_t index;
+ const std::size_t length;
+ std::size_t index;
public:
/// Instantiate the constant text driver.
virtual ~TextConstant();
/// Read the text data.
- size_t read(char * buffer, size_t size);
+ std::size_t read(char * buffer, std::size_t size);
/// Return the amount of bytes ready for read.
- size_t ready();
+ std::size_t ready();
};
TextConstant::TextConstant(const char * parameters)
{
}
- size_t
- TextConstant::read(char * buffer, size_t size)
+ std::size_t
+ TextConstant::read(char * buffer, std::size_t size)
{
- const size_t available = length - index;
+ const std::size_t available = length - index;
if ( available == 0 ) {
/// A real I/O device would block if this happened, so throw an error.
return size;
}
- size_t
+ std::size_t
TextConstant::ready()
{
return length - index;
/// Return the amount of audio samples for read. In this case, it always
/// returns SIZE_MAX.
- size_t ready();
+ std::size_t ready();
/// Generate a sine wave.
float sine_wave(float frequency, unsigned int step);
virtual ~Tone();
// Read audio into the "short" type.
- virtual std::size_t read16(int16_t * array, std::size_t length);
+ virtual std::size_t read16(std::int16_t * array, std::size_t length);
};
Tone::Tone(const char * parameters)
}
std::size_t
- Tone::read16(int16_t * array, std::size_t length)
+ Tone::read16(std::int16_t * array, std::size_t length)
{
const unsigned int array_length = ((sizeof(tones) / sizeof(*tones)) - 1);
// sum of amplitudes is 1.0.
if ( sumOfAmplitudes > 1.0 )
value /= sumOfAmplitudes;
- array[i] = (int16_t)rint(value * master_amplitude * ((1 << 15) - 1));
+ array[i] = (std::int16_t)rint(value * master_amplitude * ((1 << 15) - 1));
}
clock = (clock + length) % SampleRate;
}
- size_t
+ std::size_t
Tone::ready()
{
return SIZE_MAX;
char *
copy_string(const char * s)
{
- const size_t length(strlen(s) + 1);
+ const std::size_t length(strlen(s) + 1);
char * copy = new char[length];
memcpy(copy, s, length);
return copy;