本文整理汇总了C++中AudioTransportSource::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioTransportSource::stop方法的具体用法?C++ AudioTransportSource::stop怎么用?C++ AudioTransportSource::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioTransportSource
的用法示例。
在下文中一共展示了AudioTransportSource::stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_file
//- LISP API -
// playback-set-file (string)fileName -> t/nil
base::cell_t set_file(base::lisp &gl, base::cell_t c, base::cells_t &) {
if (base::lisp::validate(c, base::cell::list(1), base::cell::typeString)) {
const auto &fname = c + 1;
// stop current playback
ts.stop();
ts.setSource(nullptr);
frs = nullptr;
AudioFormatReader *r;
// ectract CUE information (if any)
std::regex cue("^(.*):(\\d+):(\\d+)$");
std::smatch result;
std::regex_search(fname->s, result, cue);
if (result.size() == 4) {
// is cue
int32 start = base::fromStr<int32>(result[2].str());
int32 end = base::fromStr<int32>(result[3].str());
int32 duration = end - start;
AudioFormatReader *tr = fm.createReaderFor(File(result[1].str()));
// start, end are in frames (1 frame = 1/75 second) - convert to sample
float samplesInOneSecond = tr->sampleRate; // AudioSubsectionReader will handle channels count
float startSecond = (float)start / 75.0f;
float durationSecond = (float)duration / 75.0f;
float startSample = startSecond * samplesInOneSecond;
float durationSamples = durationSecond * samplesInOneSecond;
// some CUE may have 0 length (play to end)
if (end <= start)
durationSamples = tr->lengthInSamples;
r = new AudioSubsectionReader(tr, (int)startSample, (int)durationSamples, true);
}
else {
// regular file
r = fm.createReaderFor(File(fname->s));
}
if (r) {
frs = new AudioFormatReaderSource(r, true);
ts.setSource(frs, 32768, &thread, r->sampleRate);
return gl.t();
}
gl.signalError(base::strs("file not found or file format not supported: ", fname->s));
return gl.nil();
}
gl.signalError("playback-set-file: invalid arguments, expected (string)");
return gl.nil();
}
示例2: buttonClicked
void buttonClicked (Button* buttonThatWasClicked) override
{
if (buttonThatWasClicked == &startStopButton)
{
if (transportSource.isPlaying())
{
transportSource.stop();
}
else
{
transportSource.setPosition (0);
transportSource.start();
}
}
else if (buttonThatWasClicked == &followTransportButton)
{
thumbnail->setFollowsTransport (followTransportButton.getToggleState());
}
}
示例3: loadFileIntoTransport
void loadFileIntoTransport (const File& audioFile)
{
// unload the previous file source and delete it..
transportSource.stop();
transportSource.setSource (nullptr);
currentAudioFileSource = nullptr;
AudioFormatReader* reader = formatManager.createReaderFor (audioFile);
if (reader != nullptr)
{
currentAudioFileSource = new AudioFormatReaderSource (reader, true);
// ..and plug it into our transport source
transportSource.setSource (currentAudioFileSource,
32768, // tells it to buffer this many samples ahead
&thread, // this is the background thread to use for reading-ahead
reader->sampleRate); // allows for sample rate correction
}
}
示例4: set_file
//- LISP API -
// playback-set-file (string)fileName -> t/nil
base::cell_t set_file(base::lisp &gl, base::cell_t c, base::cells_t &) {
if (base::lisp::validate(c, base::cell::list(1), base::cell::typeString)) {
const auto &fname = c + 1;
// stop current playback
ts.stop();
ts.setSource(nullptr);
frs = nullptr;
AudioFormatReader *r;
// ectract CUE information (if any)
std::regex cue("^(.*):(\\d+):(\\d+)$");
std::smatch result;
std::regex_search(fname->s, result, cue);
if (result.size() == 4) {
// is cue
int32 start = base::fromStr<int32>(result[2].str());
int32 end = base::fromStr<int32>(result[3].str());
AudioFormatReader *tr = fm.createReaderFor(File(result[1].str()));
r = new AudioSubsectionReader(tr, start, end - start, true);
}
else {
// regular file
r = fm.createReaderFor(File(fname->s));
}
if (r) {
frs = new AudioFormatReaderSource(r, true);
ts.setSource(frs, 32768, &thread, r->sampleRate);
return gl.t();
}
gl.signalError(base::strs("file not found or file format not supported: ", fname->s));
return gl.nil();
}
gl.signalError("playback-set-file: invalid arguments, expected (string)");
return gl.nil();
}
示例5: stop
// playback-stop
base::cell_t stop(base::lisp &gl, base::cell_t, base::cells_t &) {
ts.stop();
return gl.nil();
}
示例6: unload_file
// playback-unload-file
base::cell_t unload_file(base::lisp &gl, base::cell_t, base::cells_t &) {
ts.stop();
ts.setSource(nullptr);
frs = nullptr;
return gl.nil();
}