arduino-audio-tools
Loading...
Searching...
No Matches
StdioStream.h
1#pragma once
2#include <unistd.h>
3#include "AudioTools/CoreAudio/AudioStreams.h"
4
5namespace audio_tools {
6
14class StdioStream : public BaseStream {
15public:
16 AudioInfo defaultConfig() {
17 AudioInfo def;
18 def.bits_per_sample = 16;
19 def.sample_rate = 44100;
20 def.channels = 2;
21 return def;
22 }
23
24 bool begin() override {
25 is_open = true;
26 return true;
27 }
28
29
30 int available() override { return DEFAULT_BUFFER_SIZE; }
31
32 size_t readBytes(uint8_t* data, size_t len) override {
33 // read from stdin
34 return ::read(0, data, len);
35 }
36
37 int availableForWrite() override { return DEFAULT_BUFFER_SIZE; }
38
39 size_t write(const uint8_t *data, size_t len) override {
40 if (!is_open)
41 return 0;
42 // write to stdout
43 return ::write(1, data, len);
44 }
45
46 void end() override {
47 is_open = false;
48 }
49
50protected:
51 bool is_open = false;
52};
53
54} // namespace audio_tools
Base class for all Streams. It relies on write(const uint8_t *buffer, size_t size) and readBytes(uint...
Definition BaseStream.h:36
Direct binary Audio Output to stdout. On linux you can hear the audio e.g. with ./generator | aplay -...
Definition StdioStream.h:14
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
Basic Audio information which drives e.g. I2S.
Definition AudioTypes.h:53
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:55
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:57
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:59
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy