SuperpoweredSDK  v2.0.2
Superpowered Audio SDK
Superpowered::Recorder Class Reference

Records audio into 16-bit WAV file, with an optional tracklist. More...

#include "SuperpoweredRecorder.h"

Public Member Functions

 Recorder (const char *tempPath)
 Creates a recorder instance. More...
 
 ~Recorder ()
 
void addToTracklist (char *artist, char *title, int becameAudibleSeconds=0, bool takeOwnership=false)
 Each recording may include a tracklist, which is a .txt file placed next to the destination audio file. More...
 
bool isFinished ()
 
bool prepare (const char *destinationPath, unsigned int samplerate, bool fadeInFadeOut, unsigned int minimumLengthSeconds)
 Prepares for recording. More...
 
unsigned int recordInterleaved (float *input, unsigned int numberOfFrames)
 Processes incoming interleaved stereo audio. More...
 
unsigned int recordNonInterleaved (float *left, float *right, unsigned int numberOfFrames)
 Processes incoming non-interleaved stereo audio. More...
 
void stop ()
 Stops recording. More...
 

Private Member Functions

 Recorder (const Recorder &)
 
Recorderoperator= (const Recorder &)
 

Private Attributes

recorderInternals * internals
 

Detailed Description

Records audio into 16-bit WAV file, with an optional tracklist.

Use this class in a real-time audio processing thread, where directly writing to a disk is not recommended. For offline processing, instead of a Superpowered Recorder use the createWAV(), writeWAV() and closeWAV() functions in SuperpoweredSimple.h. One instance allocates around 135k * numChannels memory when recording starts.

Constructor & Destructor Documentation

◆ Recorder() [1/2]

Superpowered::Recorder::Recorder ( const char *  tempPath)

Creates a recorder instance.

Warning
Filesystem paths in C are different than paths in Java. /sdcard becomes /mnt/sdcard for example.
Parameters
tempPathThe full filesystem path of a temporary file. The recorder will create and write into this while recording.

◆ ~Recorder()

Superpowered::Recorder::~Recorder ( )

◆ Recorder() [2/2]

Superpowered::Recorder::Recorder ( const Recorder )
private

Member Function Documentation

◆ addToTracklist()

void Superpowered::Recorder::addToTracklist ( char *  artist,
char *  title,
int  becameAudibleSeconds = 0,
bool  takeOwnership = false 
)

Each recording may include a tracklist, which is a .txt file placed next to the destination audio file.

This method adds an entry to the tracklist. The tracklist file will not be created if this method is never called. Do not call this in a real-time audio processing thread.

Parameters
artistArtist, can be NULL.
titleTitle, can be NULL.
becameAudibleSecondsWhen the current track begins to be audible in this recording, relative to "now". For example, 0 means "now", -10 means "10 seconds ago".
takeOwnershipIf true, this class will free() artist and title.

◆ isFinished()

bool Superpowered::Recorder::isFinished ( )
Returns
Returns true is the recorder has finished writing after stop() was called, so the recording is fully available at the destination path. It's safe to call this method in any thread.

◆ operator=()

Recorder& Superpowered::Recorder::operator= ( const Recorder )
private

◆ prepare()

bool Superpowered::Recorder::prepare ( const char *  destinationPath,
unsigned int  samplerate,
bool  fadeInFadeOut,
unsigned int  minimumLengthSeconds 
)

Prepares for recording.

The actual recording will begin on the first call of the process() method.

Returns
Returns true on success or false if another recording is still active or not finished writing to disk yet. Do not call this in a real-time audio processing thread.
Parameters
destinationPathThe full filesystem path of the successfully finished recording. Do not include ".wav" in this, the .wav extension will be automatically appended.
samplerateThe sample rate of the audio input and the recording, in Hz. The input sample rate must remain the same during the entire recording.
fadeInFadeOutIf true, the recorder applies a fade-in at the beginning and a fade-out at the end of the recording. The fade is 64 frames long.
minimumLengthSecondsThe minimum length of the recording. If the number of recorded seconds is lower, then a file will not be saved.

◆ recordInterleaved()

unsigned int Superpowered::Recorder::recordInterleaved ( float *  input,
unsigned int  numberOfFrames 
)

Processes incoming interleaved stereo audio.

Returns
Seconds recorded so far. It's never blocking for real-time usage.
Parameters
inputPointer to floating point numbers. Stereo interleaved audio to record.
numberOfFramesThe number of frames in input.

◆ recordNonInterleaved()

unsigned int Superpowered::Recorder::recordNonInterleaved ( float *  left,
float *  right,
unsigned int  numberOfFrames 
)

Processes incoming non-interleaved stereo audio.

Returns
Seconds recorded so far. It's never blocking for real-time usage.
Parameters
leftPointer to floating point numbers. Left input channel.
rightPointer to floating point numbers. Right input channel.
numberOfFramesThe number of frames in input.

◆ stop()

void Superpowered::Recorder::stop ( )

Stops recording.

After calling stop() the recorder needs a little bit more time to write the last pieces of audio to disk. You can periodically call isFinished() to check when it's done. It's safe to call this method in any thread.

Member Data Documentation

◆ internals

recorderInternals* Superpowered::Recorder::internals
private

The documentation for this class was generated from the following file: