maix.audio
maix.audio module
You can use
maix.audio
to access this module with MaixPy
This module is generated from MaixPy and MaixCDK
Module
No module
Enum
Format
Audio type
item | describe |
---|---|
values | FMT_NONE: format invalid FMT_S8: unsigned 8 bits FMT_S16_LE: signed 16 bits, little endian FMT_S32_LE: signed 32 bits, little endian FMT_S16_BE: signed 16 bits, big endian FMT_S32_BE: signed 32 bits, big endian FMT_U8: unsigned 8 bits FMT_U16_LE: unsigned 16 bits, little endian FMT_U32_LE: unsigned 32 bits, little endian FMT_U16_BE: unsigned 16 bits, big endian FMT_U32_BE: unsigned 32 bits, big endian |
C++ defination code:
enum Format { FMT_NONE = 0, // format invalid FMT_S8, // unsigned 8 bits FMT_S16_LE, // signed 16 bits, little endian FMT_S32_LE, // signed 32 bits, little endian FMT_S16_BE, // signed 16 bits, big endian FMT_S32_BE, // signed 32 bits, big endian FMT_U8, // unsigned 8 bits FMT_U16_LE, // unsigned 16 bits, little endian FMT_U32_LE, // unsigned 32 bits, little endian FMT_U16_BE, // unsigned 16 bits, big endian FMT_U32_BE, // unsigned 32 bits, big endian }
Variable
Function
Class
Recorder
Recorder class
C++ defination code:
class Recorder
__init__
def __init__(self, path: str = '', sample_rate: int = 48000, format: Format = ..., channel: int = 1) -> None
Construct a new Recorder object. currectly only pcm and wav formats supported.
item | description |
---|---|
type | func |
param | path: record path. the path determines the location where you save the file, if path is none, the audio module will not save file. sample_rate: record sample rate, default is 48000(48KHz), means 48000 samples per second. format: record sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format channel: record sample channel, default is 1, means 1 channel sampling at the same time |
static | False |
C++ defination code:
Recorder(std::string path = std::string(), int sample_rate = 48000, audio::Format format = audio::Format::FMT_S16_LE, int channel = 1)
volume
def volume(self, value: int = -1) -> int
Set/Get record volume
item | description |
---|---|
type | func |
param | value: volume value, If you use this parameter, audio will set the value to volume, if you don't, it will return the current volume. range is [0, 100]. |
return | the current volume |
static | False |
C++ defination code:
int volume(int value = -1)
mute
def mute(self, data: int = -1) -> bool
Mute
item | description |
---|---|
type | func |
param | data: mute data, If you set this parameter to true, audio will set the value to mute, if you don't, it will return the current mute status. |
return | Returns whether mute is currently enabled. |
static | False |
C++ defination code:
bool mute(int data = -1)
record
def record(*args, **kwargs)
Record, Read all cached data in buffer and return. If there is no audio data in the buffer, may return empty data.
item | description |
---|---|
type | func |
param | record_ms: Block and record audio data lasting record_ms milliseconds and save it to a file, the return value does not return audio data. Only valid if the initialisation path is set. |
return | pcm data. datatype @see Bytes. If you pass in record_ms parameter, the return value is an empty Bytes object. |
static | False |
C++ defination code:
maix::Bytes *record(int record_ms = -1)
finish
def finish(self) -> maix.err.Err
Finish the record, if you have passed in the path, this api will save the audio data to file.
item | description |
---|---|
type | func |
return | error code, err::ERR_NONE means success, others means failed |
static | False |
C++ defination code:
err::Err finish()
sample_rate
def sample_rate(self) -> int
Get sample rate
item | description |
---|---|
type | func |
return | returns sample rate |
static | False |
C++ defination code:
int sample_rate()
format
def format(self) -> Format
Get sample format
item | description |
---|---|
type | func |
return | returns sample format |
static | False |
C++ defination code:
audio::Format format()
channel
def channel(self) -> int
Get sample channel
item | description |
---|---|
type | func |
return | returns sample channel |
static | False |
C++ defination code:
int channel()
Player
Player class
C++ defination code:
class Player
__init__
def __init__(self, path: str = '', sample_rate: int = 48000, format: Format = ..., channel: int = 1) -> None
Construct a new Player object
item | description |
---|---|
type | func |
param | path: player path. the path determines the location where you save the file, if path is none, the audio module will not save file. sample_rate: player sample rate, default is 48000(48KHz), means 48000 samples per second. format: player sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format channel: player sample channel, default is 1, means 1 channel sampling at the same time |
static | False |
C++ defination code:
Player(std::string path = std::string(), int sample_rate = 48000, audio::Format format = audio::Format::FMT_S16_LE, int channel = 1)
volume
def volume(self, value: int = -1) -> int
Set/Get player volume
item | description |
---|---|
type | func |
param | value: volume value, If you use this parameter, audio will set the value to volume, if you don't, it will return the current volume. range is [0, 100]. |
return | the current volume |
static | False |
C++ defination code:
int volume(int value = -1)
play
def play(self, data: maix.Bytes(bytes) = b'') -> maix.err.Err
Play
item | description |
---|---|
type | func |
param | data: audio data, must be raw data |
return | error code, err::ERR_NONE means success, others means failed |
static | False |
C++ defination code:
err::Err play(maix::Bytes *data = maix::audio::Player::NoneBytes)
sample_rate
def sample_rate(self) -> int
Get sample rate
item | description |
---|---|
type | func |
return | returns sample rate |
static | False |
C++ defination code:
int sample_rate()
format
def format(self) -> Format
Get sample format
item | description |
---|---|
type | func |
return | returns sample format |
static | False |
C++ defination code:
audio::Format format()
channel
def channel(self) -> int
Get sample channel
item | description |
---|---|
type | func |
return | returns sample channel |
static | False |
C++ defination code:
int channel()