mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
Merge pull request #209 from georgkrause/sanitycheck
Sanity check for bpm input, thanks @georgkrause !
This commit is contained in:
commit
60d9c852b3
2 changed files with 12 additions and 5 deletions
|
@ -51,6 +51,10 @@
|
||||||
#define NSCENES 10
|
#define NSCENES 10
|
||||||
#define MAX_BUFFER_SIZE 1024
|
#define MAX_BUFFER_SIZE 1024
|
||||||
|
|
||||||
|
/// TEMPO
|
||||||
|
#define MIN_TEMPO 60
|
||||||
|
#define MAX_TEMPO 220
|
||||||
|
|
||||||
#define CONTROLLERS_PREALLOC 20
|
#define CONTROLLERS_PREALLOC 20
|
||||||
|
|
||||||
// nsamples remaining during recording before Looper requests larger buffer
|
// nsamples remaining during recording before Looper requests larger buffer
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
|
static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
|
||||||
{
|
{
|
||||||
Avtk::Dial* b = (Avtk::Dial*)w;
|
Avtk::Dial* b = (Avtk::Dial*)w;
|
||||||
float bpm = (int)(b->value() * 160.f + 60);
|
float bpm = (int)(b->value() * (float)(MAX_TEMPO - MIN_TEMPO) + MIN_TEMPO);
|
||||||
if(std::fabs(bpm-round(bpm))) {
|
if(std::fabs(bpm-round(bpm))) {
|
||||||
LUPPP_WARN("%f",bpm);
|
LUPPP_WARN("%f",bpm);
|
||||||
}
|
}
|
||||||
|
@ -170,12 +170,15 @@ static void gmastertrack_button_callback(Fl_Widget *w, void *data)
|
||||||
|
|
||||||
} else if ( strcmp( w->label(), "Tap" ) == 0 ) {
|
} else if ( strcmp( w->label(), "Tap" ) == 0 ) {
|
||||||
if ( Fl::event_button() == FL_RIGHT_MOUSE ) {
|
if ( Fl::event_button() == FL_RIGHT_MOUSE ) {
|
||||||
const char* answer = fl_input("Enter BPM value: ");
|
const char* answer = fl_input("Enter BPM value (range %d and %d):", 0, MIN_TEMPO, MAX_TEMPO);
|
||||||
if(answer) {
|
if(answer) {
|
||||||
int bpm = atoi(answer);
|
int bpm = atoi(answer);
|
||||||
|
|
||||||
|
if ( bpm >= MIN_TEMPO && bpm <= MAX_TEMPO) {
|
||||||
EventTimeBPM e = EventTimeBPM( bpm );
|
EventTimeBPM e = EventTimeBPM( bpm );
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
EventTimeTempoTap e;
|
EventTimeTempoTap e;
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
|
@ -269,7 +272,7 @@ GMasterTrack::GMasterTrack(int x, int y, int w, int h, const char* l ) :
|
||||||
void GMasterTrack::setBpm( int b )
|
void GMasterTrack::setBpm( int b )
|
||||||
{
|
{
|
||||||
bpm = b;
|
bpm = b;
|
||||||
tempoDial.value( ( bpm - 60 ) / 160.f );
|
tempoDial.value( ( bpm - MIN_TEMPO ) / (float)(MAX_TEMPO - MIN_TEMPO) );
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << bpm;
|
s << bpm;
|
||||||
tempoDial.copy_label( s.str().c_str() );
|
tempoDial.copy_label( s.str().c_str() );
|
||||||
|
|
Loading…
Add table
Reference in a new issue