MCPcopy Create free account
hub / github.com/cinder/Cinder / setup

Method setup

samples/_audio/VoiceBasicProcessing/src/VoiceBasicProcessingApp.cpp:31–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29};
30
31void VoiceBasicProcessingApp::setup()
32{
33 mFreq = 0;
34 mPhase = 0;
35
36 mVoice = audio::Voice::create( [this] ( audio::Buffer *buffer, size_t sampleRate ) {
37
38 float *channel0 = buffer->getChannel( 0 );
39
40#if 1
41 // generate a sine wave
42 float phaseIncr = ( mFreq / (float)sampleRate ) * 2 * (float)M_PI;
43 for( size_t i = 0; i < buffer->getNumFrames(); i++ ) {
44 mPhase = fmodf( mPhase + phaseIncr, 2 * M_PI );
45 channel0[i] = std::sin( mPhase );
46 }
47#else
48 // generate a triangle wave
49 float phaseIncr = ( mFreq / (float)sampleRate );
50 for( size_t i = 0; i < buffer->getNumFrames(); i++ ) {
51 mPhase = fmodf( mPhase + phaseIncr, 1 );
52 channel0[i] = std::min( mPhase, 1 - mPhase );
53 }
54#endif
55 } );
56
57 mVoice->start();
58}
59
60void VoiceBasicProcessingApp::mouseDown( MouseEvent event )
61{

Callers

nothing calls this directly

Calls 6

sinFunction · 0.85
getChannelMethod · 0.80
createFunction · 0.50
minFunction · 0.50
getNumFramesMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected