本文整理汇总了C++中TimeRange类的典型用法代码示例。如果您正苦于以下问题:C++ TimeRange类的具体用法?C++ TimeRange怎么用?C++ TimeRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimeRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isInRange_cc
bool Rythmos::isInRange_cc(const TimeRange<TimeType> &tr, const TimeType &p)
{
return (
compareTimeValues(p,tr.lower()) >= 0
&& compareTimeValues(p,tr.upper()) <= 0
);
}
示例2: TEUCHOS_UNIT_TEST
TEUCHOS_UNIT_TEST( Rythmos_TimeRange, copyAndScaleInvalid ) {
TimeRange<double> tr;
TimeRange<double> newTr = tr.copyAndScale(5.0);
TEST_EQUALITY_CONST( newTr.isValid(), false );
TEST_EQUALITY( newTr.lower(), tr.lower() );
TEST_EQUALITY( newTr.upper(), tr.upper() );
TEST_EQUALITY( newTr.length(), tr.length() );
}
示例3: translateTimeRange
Scalar translateTimeRange(
Scalar t,
const TimeRange<Scalar>& sourceRange,
const TimeRange<Scalar>& destinationRange
) {
Scalar r = destinationRange.length()/sourceRange.length();
return r*t+destinationRange.lower()-r*sourceRange.lower();
}
示例4: ostab
void ImplicitBDFStepperRampingStepControl<Scalar>::initialize(
const StepperBase<Scalar>& stepper)
{
// Initialize can be called from the stepper when setInitialCondition
// is called.
using Teuchos::as;
typedef Teuchos::ScalarTraits<Scalar> ST;
using Thyra::createMember;
// Set initial time:
TimeRange<Scalar> stepperRange = stepper.getTimeRange();
TEUCHOS_TEST_FOR_EXCEPTION(
!stepperRange.isValid(),
std::logic_error,
"Error, Stepper does not have valid time range for initialization "
"of ImplicitBDFStepperRampingStepControl!\n");
if (is_null(parameterList_)) {
RCP<Teuchos::ParameterList> emptyParameterList =
Teuchos::rcp(new Teuchos::ParameterList);
this->setParameterList(emptyParameterList);
}
if (is_null(errWtVecCalc_)) {
RCP<ImplicitBDFStepperErrWtVecCalc<Scalar> > IBDFErrWtVecCalc =
rcp(new ImplicitBDFStepperErrWtVecCalc<Scalar>());
errWtVecCalc_ = IBDFErrWtVecCalc;
}
stepControlState_ = UNINITIALIZED;
requestedStepSize_ = Scalar(-1.0);
currentStepSize_ = initialStepSize_;
currentOrder_ = 1;
nextStepSize_ = initialStepSize_;
nextOrder_ = 1;
numberOfSteps_ = 0;
totalNumberOfFailedSteps_ = 0;
countOfConstantStepsAfterFailure_ = 0;
if (is_null(delta_)) {
delta_ = createMember(stepper.get_x_space());
}
if (is_null(errWtVec_)) {
errWtVec_ = createMember(stepper.get_x_space());
}
V_S(delta_.ptr(),ST::zero());
if ( doOutput_(Teuchos::VERB_HIGH) ) {
RCP<Teuchos::FancyOStream> out = this->getOStream();
Teuchos::OSTab ostab(out,1,"initialize");
*out << "currentOrder_ = " << currentOrder_ << std::endl;
*out << "numberOfSteps_ = " << numberOfSteps_ << std::endl;
}
setStepControlState_(BEFORE_FIRST_STEP);
}
示例5: GetMarkers
void AudioMarkerProviderKeyframes::GetMarkers(TimeRange const& range, AudioMarkerVector &out) const {
// Find first and last keyframes inside the range
auto a = lower_bound(markers.begin(), markers.end(), range.begin());
auto b = upper_bound(markers.begin(), markers.end(), range.end());
// Place pointers to the markers in the output vector
for (; a != b; ++a)
out.push_back(&*a);
}
示例6: PlayRange
void AudioController::PlayRange(const TimeRange &range)
{
if (!IsAudioOpen()) return;
player->Play(SamplesFromMilliseconds(range.begin()), SamplesFromMilliseconds(range.length()));
playback_mode = PM_Range;
playback_timer.Start(20);
AnnouncePlaybackPosition(range.begin());
}
示例7: if
string GenlistItemScenarioSchedule::getLabelItem(Evas_Object *obj, string part)
{
string text;
if (!scenario) return text;
if (part == "text")
{
text = scenario->ioScenario->params["name"];
}
else if (part == "time")
{
text = "N/A";
if (scenario->isScheduled())
{
auto getTimeForDate = [=,&text](vector<TimeRange> &range)
{
if (scheduleRangeNum >= 0 && scheduleRangeNum < range.size())
{
TimeRange tr = range[scheduleRangeNum];
text = tr.getStartTimeSec(scDate.tm_year + 1900, scDate.tm_mon + 1, scDate.tm_mday);
}
};
switch (scheduleRange)
{
case TimeRange::MONDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_monday); break;
case TimeRange::TUESDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_tuesday); break;
case TimeRange::WEDNESDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_wednesday); break;
case TimeRange::THURSDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_thursday); break;
case TimeRange::FRIDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_friday); break;
case TimeRange::SATURDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_saturday); break;
case TimeRange::SUNDAY: getTimeForDate(scenario->ioSchedule->range_infos.range_sunday); break;
default: break;
}
}
}
else if (part == "actions.text")
{
text = "Aucune actions.";
if (scenario->scenario_data.steps.size() > 1)
text = Utils::to_string(scenario->scenario_data.steps.size()) + " étapes.";
else if (scenario->scenario_data.steps.size() == 1 &&
scenario->scenario_data.steps[0].actions.size() > 0)
text = Utils::to_string(scenario->scenario_data.steps[0].actions.size()) + " actions.";
}
if (scenario->scenario_data.params["schedule"] != "false")
itemEmitSignal("schedule,true", "calaos");
else
itemEmitSignal("schedule,false", "calaos");
return text;
}
示例8: GetMarkers
void AudioTimingControllerKaraoke::GetMarkers(TimeRange const& range, AudioMarkerVector &out) const {
size_t i;
for (i = 0; i < markers.size() && markers[i] < range.begin(); ++i) ;
for (; i < markers.size() && markers[i] < range.end(); ++i)
out.push_back(&markers[i]);
if (range.contains(start_marker)) out.push_back(&start_marker);
if (range.contains(end_marker)) out.push_back(&end_marker);
keyframes_provider.GetMarkers(range, out);
video_position_provider.GetMarkers(range, out);
}
示例9: GetMarkers
void SecondsMarkerProvider::GetMarkers(TimeRange const& range, AudioMarkerVector &out) const {
if (!enabled->GetBool()) return;
if ((range.length() + 999) / 1000 > (int)markers.size())
markers.resize((range.length() + 999) / 1000, Marker(pen.get()));
size_t i = 0;
for (int time = ((range.begin() + 999) / 1000) * 1000; time < range.end(); time += 1000) {
markers[i].position = time;
out.push_back(&markers[i++]);
}
}
示例10: asssertInTimeRange
void Rythmos::asssertInTimeRange( const TimeRange<TimeType> &timeRange,
const TimeType &time )
{
TEUCHOS_TEST_FOR_EXCEPTION( !timeRange.isInRange(time), std::out_of_range,
"Error, the time = " << time
<< " is out of the range = " << timeRange << "!"
);
}
示例11: TEST_FOR_EXCEPTION
void Rythmos::assertNoTimePointsInsideCurrentTimeRange(
const InterpolationBufferBase<Scalar>& interpBuffer,
const Array<Scalar>& time_vec
)
{
typedef ScalarTraits<Scalar> ST;
const int numTimePoints = time_vec.size();
const TimeRange<Scalar> currentTimeRange = interpBuffer.getTimeRange();
if (currentTimeRange.length() >= ST::zero()) {
for ( int i = 0; i < numTimePoints; ++i ) {
TEST_FOR_EXCEPTION(
currentTimeRange.isInRange(time_vec[i]), std::out_of_range,
"Error, time_vec["<<i<<"] = " << time_vec[i] << " is in TimeRange of "
<< interpBuffer.description() << " = ["
<< currentTimeRange.lower() << "," << currentTimeRange.upper() << "]!"
);
}
}
}
示例12: PaintAudio
void AudioDisplay::PaintAudio(wxDC &dc, TimeRange updtime, wxRect updrect)
{
auto pt = style_ranges.upper_bound(updtime.begin());
auto pe = style_ranges.upper_bound(updtime.end());
if (pt != style_ranges.begin())
--pt;
while (pt != pe)
{
AudioRenderingStyle range_style = static_cast<AudioRenderingStyle>(pt->second);
int range_x1 = std::max(updrect.x, RelativeXFromTime(pt->first));
int range_x2 = (++pt == pe) ? updrect.x + updrect.width : RelativeXFromTime(pt->first);
if (range_x2 > range_x1)
{
audio_renderer->Render(dc, wxPoint(range_x1, audio_top), range_x1 + scroll_left, range_x2 - range_x1, range_style);
}
}
}
示例13: ScrollTimeRangeInView
void AudioDisplay::ScrollTimeRangeInView(const TimeRange &range)
{
int client_width = GetClientRect().GetWidth();
int range_begin = AbsoluteXFromTime(range.begin());
int range_end = AbsoluteXFromTime(range.end());
int range_len = range_end - range_begin;
// Remove 5 % from each side of the client area.
int leftadjust = client_width / 20;
int client_left = scroll_left + leftadjust;
client_width = client_width * 9 / 10;
// Is everything already in view?
if (range_begin >= client_left && range_end <= client_left+client_width)
return;
// The entire range can fit inside the view, center it
if (range_len < client_width)
{
ScrollPixelToLeft(range_begin - (client_width-range_len)/2 - leftadjust);
}
// Range doesn't fit in view and we're viewing a middle part of it, just leave it alone
else if (range_begin < client_left && range_end > client_left+client_width)
{
// nothing
}
// Right edge is in view, scroll it as far to the right as possible
else if (range_end >= client_left && range_end < client_left+client_width)
{
ScrollPixelToLeft(range_end - client_width - leftadjust);
}
// Nothing is in view or the left edge is in view, scroll left edge as far to the left as possible
else
{
ScrollPixelToLeft(range_begin - leftadjust);
}
}
示例14: webRtcDetectVoiceActivity
JoiningBoundedTimeline<void> webRtcDetectVoiceActivity(const AudioClip& audioClip, ProgressSink& progressSink) {
VadInst* vadHandle = WebRtcVad_Create();
if (!vadHandle) throw runtime_error("Error creating WebRTC VAD handle.");
auto freeHandle = gsl::finally([&]() {
WebRtcVad_Free(vadHandle);
});
int error = WebRtcVad_Init(vadHandle);
if (error) throw runtime_error("Error initializing WebRTC VAD handle.");
const int aggressiveness = 2; // 0..3. The higher, the more is cut off.
error = WebRtcVad_set_mode(vadHandle, aggressiveness);
if (error) throw runtime_error("Error setting WebRTC VAD aggressiveness.");
ProgressMerger progressMerger(progressSink);
ProgressSink& pass1ProgressSink = progressMerger.addSink(1.0);
ProgressSink& pass2ProgressSink = progressMerger.addSink(0.3);
// Detect activity
JoiningBoundedTimeline<void> activity(audioClip.getTruncatedRange());
centiseconds time = 0_cs;
const size_t bufferCapacity = audioClip.getSampleRate() / 100;
auto processBuffer = [&](const vector<int16_t>& buffer) {
// WebRTC is picky regarding buffer size
if (buffer.size() < bufferCapacity) return;
int result = WebRtcVad_Process(vadHandle, audioClip.getSampleRate(), buffer.data(), buffer.size()) == 1;
if (result == -1) throw runtime_error("Error processing audio buffer using WebRTC VAD.");
bool isActive = result != 0;
if (isActive) {
activity.set(time, time + 1_cs);
}
time += 1_cs;
};
process16bitAudioClip(audioClip, processBuffer, bufferCapacity, pass1ProgressSink);
// WebRTC adapts to the audio. This means results may not be correct at the very beginning.
// It sometimes returns false activity at the very beginning, mistaking the background noise for speech.
// So we delete the first recognized utterance and re-process the corresponding audio segment.
if (!activity.empty()) {
TimeRange firstActivity = activity.begin()->getTimeRange();
activity.clear(firstActivity);
unique_ptr<AudioClip> streamStart = audioClip.clone() | segment(TimeRange(0_cs, firstActivity.getEnd()));
time = 0_cs;
process16bitAudioClip(*streamStart, processBuffer, bufferCapacity, pass2ProgressSink);
}
return activity;
}
示例15: selectPointsInTimeRange
void Rythmos::selectPointsInTimeRange(
const Array<TimeType>& points_in,
const TimeRange<TimeType>& range,
const Ptr<Array<TimeType> >& points_out
)
{
points_out->clear();
int Nt = Teuchos::as<int>(points_in.size());
for (int i=0; i < Nt ; ++i) {
if (range.isInRange(points_in[i])) {
points_out->push_back(points_in[i]);
}
}
}