Yet Another Synthesizer Engine
 
Loading...
Searching...
No Matches
yase::Sampler Class Reference

#include <sampler.hh>

+ Inheritance diagram for yase::Sampler:
+ Collaboration diagram for yase::Sampler:

Detailed Description

Record a sample.

Record a sample and save it to a file as a wav. For example, here is how you can use it to record something from your Audio input.

int main(int argc, char * argv[]) {
Audio audio(2,1);
Sampler sampler(argv[1]);
Container container;
container.add(sampler)
.add(audio)
.connect(audio, "line_in0", sampler, "signal");
sampler.record();
container.run(UNTIL_INTERRUPTED);
sampler.stop()
.write();
return 0;
}
A module wrapper for a stereo PortAudio interface (http://www.portaudio.com/).
Definition audio.hh:46
A module and event manager that can contain other modules.
Definition container.hh:63
Container & connect(Module &source, string output, Module &dest, string input)
Definition container.cc:111
void run(int num_steps)
Definition container.cc:374
Container & add(Module &module)
Definition container.cc:62
Record a sample.
Definition sampler.hh:55
#define UNTIL_INTERRUPTED
Use as in Synthesizer::run(UNTIL_INTERUPTED)
Definition globals.hh:27
Parameters
[in]signalThe signal to record

Public Member Functions

 Sampler (string path)
 
void init ()
 
void update ()
 
Samplerrecord ()
 Turn on the Sampler so that it records its input.
 
Samplerstop ()
 Turn off the Sample so that it stops recording.
 
Samplerwrite ()
 
- Public Member Functions inherited from yase::Module
virtual void init ()=0
 
virtual void update ()=0
 
int add_input (string name)
 
int add_output (string name)
 
int get_input_index (string name) const
 
string get_input_name (int index) const
 
string get_output_name (int index) const
 
int get_output_index (string name) const
 
void set_input (string name, double value)
 
void set_input (int index, double value)
 
double get_input (int index) const
 
double get_input (string name) const
 
double get_output (string name) const
 
double get_output (int index) const
 
void set_output (int index, double value)
 
void copy_inputs (const Module &source)
 
void copy_outputs (Module &destination) const
 
void configure (std::vector< std::tuple< string, double > > assignments)
 
int num_inputs () const
 
int num_outputs () const
 
void emit (Event e)
 
void set_ts (double s)
 
double get_ts ()
 

Public Attributes

const int BUFFER_LENGTH = SAMPLE_RATE
 

Constructor & Destructor Documentation

◆ Sampler()

yase::Sampler::Sampler ( string  path)

Construct a Sampler Module

Parameters
pathThe path to write the resulting wav file to

Member Function Documentation

◆ init()

void yase::Sampler::init ( )
virtual

This method should be overridden by derived classes. It will usually be called once, after all modules and connections objects have been added to a synthesizer, but before the synthesizer starts running.

Implements yase::Module.

◆ update()

void yase::Sampler::update ( )
virtual

This method should be overridden by derived classes. It will be called repeatedly by a synthesizer at a frequency determined by SAMPLE_RATE.

Implements yase::Module.

◆ write()

Sampler & yase::Sampler::write ( )

Save the recorded signal to the file specified by the path parameter when the Sampler Module was constructed.


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