/* store the phase of the generated waveform */ struct synth_state {
synth_state(int num_channels_, float sample_rate_)
: num_channels(num_channels_), sample_rate(sample_rate_)
{ for (int i = 0; i < MAX_NUM_CHANNELS; ++i)
phase[i] = 0.0f;
}
template <typename T> void run(T * audiobuffer, long nframes)
{ for (int c = 0; c < num_channels; ++c) { float freq = get_frequency(c); float phase_inc = 2.0 * M_PI * freq / sample_rate; for (long n = 0; n < nframes; ++n) {
audiobuffer[n * num_channels + c] =
ConvertSample<T>(sin(phase[c]) * VOLUME);
phase[c] += phase_inc;
}
}
}
private: int num_channels; float phase[MAX_NUM_CHANNELS]; float sample_rate;
};
/* Our android backends don't support float, only int16. */ int
supports_float32(string backend_id)
{ return backend_id != "opensl" && backend_id != "audiotrack";
}
/* Some backends don't have code to deal with more than mono or stereo. */ int
supports_channel_count(string backend_id, int nchannels)
{ return nchannels <= 2 ||
(backend_id != "opensl" && backend_id != "audiotrack");
}
int
run_test(int num_channels, int sampling_rate, int is_float)
{ int r = CUBEB_OK;
if ((is_float && !supports_float32(backend_id)) ||
!supports_channel_count(backend_id, num_channels)) { /* don't treat this as a test failure. */ return CUBEB_OK;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.