Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
/*****************************************************************************
GateOut.cpp
Copyright (c) 2020 Raphael DINGE
*Tab=3***********************************************************************/
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "erb/GateOut.h"
namespace erb
{
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*
==============================================================================
Name : on
==============================================================================
*/
void GateOut::on ()
{
_mode = Mode::Constant;
_current = true;
}
/*
==============================================================================
Name : off
==============================================================================
*/
void GateOut::off ()
{
_mode = Mode::Constant;
_current = false;
}
/*
==============================================================================
Name : trigger
==============================================================================
*/
void GateOut::trigger (std::chrono::milliseconds duration)
{
_mode = Mode::Pulse;
_start = *_now_ms_ptr;
_duration = uint64_t (duration.count ());
_current = true;
}
/*\\\ INTERNAL \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*
==============================================================================
Name : impl_bind_data
==============================================================================
*/
void GateOut::impl_bind_data (uint8_t & val)
{
_val_ptr = &val;
}
/*
==============================================================================
Name : impl_bind_clock
==============================================================================
*/
void GateOut::impl_bind_clock (const uint64_t & clock_ms)
{
_clock_ms_ptr = &clock_ms;
}
/*
==============================================================================
Name : impl_notify_audio_buffer_start
==============================================================================
*/
void GateOut::impl_notify_audio_buffer_start ()
{
if (_mode == Mode::Pulse)
{
auto elapsed = *_clock_ms_ptr - _start;
_current = elapsed < _duration;
}
*_val_ptr = _current ? 1 : 0;
}
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
} // namespace erb
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
8b8937c75This file is pinned to the selected release. Download the original to open it in your design tool.