mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-04 16:51:37 -05:00
Fixed #86, metronome volume. Use right-click
This commit is contained in:
parent
d75ca042ec
commit
d4f74b6c45
6 changed files with 83 additions and 6 deletions
|
@ -33,6 +33,7 @@ const char* EventTrackRecordArm::prettyName = "track:record_arm";
|
|||
const char* EventTimeBPM::prettyName = "tempo_bpm";
|
||||
const char* EventTimeTempoTap::prettyName = "tempo_tap";
|
||||
const char* EventMetronomeActive::prettyName = "metronome:active";
|
||||
const char* EventMetronomeVolume::prettyName = "metronome:volume";
|
||||
|
||||
const char* EventGridEvent::prettyName = "grid:event";
|
||||
const char* EventGridLaunchScene::prettyName = "grid:launch_scene";
|
||||
|
@ -75,6 +76,7 @@ const char* Event::getPrettyName( int type )
|
|||
case GRID_LAUNCH_SCENE:{ return EventGridLaunchScene::prettyName; }
|
||||
|
||||
case METRONOME_ACTIVE:{ return EventMetronomeActive::prettyName; }
|
||||
case METRONOME_VOLUME:{ return EventMetronomeVolume::prettyName; }
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ namespace Event
|
|||
|
||||
/// Transport etc
|
||||
METRONOME_ACTIVE,
|
||||
METRONOME_VOLUME,
|
||||
TRANSPORT, /// rolling or stopped
|
||||
|
||||
TIME_BPM,
|
||||
|
@ -566,6 +567,18 @@ class EventMetronomeActive : public EventBase
|
|||
EventMetronomeActive(bool a = false) : active(a) {}
|
||||
};
|
||||
|
||||
class EventMetronomeVolume : public EventBase
|
||||
{
|
||||
public:
|
||||
int type() { return int(METRONOME_VOLUME); }
|
||||
uint32_t size() { return sizeof(EventMetronomeVolume); }
|
||||
static const char* prettyName;
|
||||
const char* name(){ return prettyName; }
|
||||
|
||||
float vol;
|
||||
EventMetronomeVolume(float v = 0.f) : vol(v){}
|
||||
};
|
||||
|
||||
class EventTimeBPM : public EventBase
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "controller/controller.hxx"
|
||||
#include "controller/genericmidi.hxx"
|
||||
#include "eventhandler.hxx"
|
||||
#include "metronome.hxx"
|
||||
|
||||
#include "logic.hxx"
|
||||
#include "state/state.hxx"
|
||||
|
@ -204,6 +205,13 @@ void handleDspEvents()
|
|||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventMetronomeActive) );
|
||||
jack->getLogic()->metronomeEnable(ev.active);
|
||||
} break; }
|
||||
case Event::METRONOME_VOLUME: {
|
||||
if ( availableRead >= sizeof(EventMetronomeVolume) ) {
|
||||
EventMetronomeVolume ev(false);
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventMetronomeVolume) );
|
||||
LUPPP_NOTE("EventDSP: MetroVol %f", ev.vol );
|
||||
jack->getMetronome()->setVolume(ev.vol);
|
||||
} break; }
|
||||
case Event::LOOPER_STATE: {
|
||||
if ( availableRead >= sizeof(EventLooperState) ) {
|
||||
EventLooperState ev;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "gmastertrack.hxx"
|
||||
|
||||
#include <FL/Fl_Menu_Item.H>
|
||||
|
||||
static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
|
||||
{
|
||||
Avtk::Dial* b = (Avtk::Dial*)w;
|
||||
|
@ -131,10 +133,52 @@ static void gmastertrack_button_callback(Fl_Widget *w, void *data)
|
|||
{
|
||||
if ( strcmp( w->label(), "Metro" ) == 0 )
|
||||
{
|
||||
Avtk::LightButton* b = (Avtk::LightButton*)w;
|
||||
b->value( !b->value() );
|
||||
EventMetronomeActive e = EventMetronomeActive( b->value() );
|
||||
writeToDspRingbuffer( &e );
|
||||
if ( Fl::event_button() == FL_RIGHT_MOUSE )
|
||||
{
|
||||
// popup volume menu: 10 "steps of volume"
|
||||
Fl_Menu_Item rclick_menu[] =
|
||||
{
|
||||
{ "Vol 100%" },
|
||||
{ "Vol 75%" },
|
||||
{ "Vol 50%" },
|
||||
{ "Vol 25%"},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup( Fl::event_x(), Fl::event_y(), 0, 0, 0);
|
||||
|
||||
float v = 0.f;
|
||||
if ( !m )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ( strcmp(m->label(), "Vol 100%") == 0 ) {
|
||||
v = 1;
|
||||
}
|
||||
else if ( strcmp(m->label(), "Vol 75%") == 0 ) {
|
||||
v = 0.75;
|
||||
}
|
||||
else if ( strcmp(m->label(), "Vol 50%") == 0 ) {
|
||||
v = 0.5;
|
||||
}
|
||||
else
|
||||
v = 0.25;
|
||||
|
||||
LUPPP_NOTE("metro vol = %f", v );
|
||||
|
||||
EventMetronomeVolume e( v );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
else
|
||||
{
|
||||
Avtk::LightButton* b = (Avtk::LightButton*)w;
|
||||
b->value( !b->value() );
|
||||
EventMetronomeActive e = EventMetronomeActive( b->value() );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if ( strcmp( w->label(), "Tap" ) == 0 )
|
||||
{
|
||||
|
|
|
@ -33,7 +33,8 @@ Metronome::Metronome() :
|
|||
TimeObserver(),
|
||||
playBar (false),
|
||||
active (false),
|
||||
playPoint (0)
|
||||
playPoint (0),
|
||||
vol (1)
|
||||
{
|
||||
// create beat and bar samples
|
||||
endPoint = ( jack->getSamplerate() / 441 );
|
||||
|
@ -57,6 +58,12 @@ void Metronome::setActive(bool a)
|
|||
playPoint = endPoint + 1;
|
||||
}
|
||||
|
||||
void Metronome::setVolume( float v )
|
||||
{
|
||||
vol = v;
|
||||
printf(" vol = %f \n", vol );
|
||||
}
|
||||
|
||||
void Metronome::bar()
|
||||
{
|
||||
playPoint = 0;
|
||||
|
@ -94,7 +101,7 @@ void Metronome::process(int nframes, Buffers* buffers)
|
|||
{
|
||||
if ( playPoint < endPoint )
|
||||
{
|
||||
out[i] += sample[playPoint];
|
||||
out[i] += sample[playPoint] * vol;
|
||||
playPoint++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,12 +40,15 @@ class Metronome : public TimeObserver
|
|||
void beat();
|
||||
void setFpb(int f);
|
||||
|
||||
void setVolume( float v );
|
||||
|
||||
void process(int nframes, Buffers* buffers);
|
||||
|
||||
private:
|
||||
int fpb;
|
||||
bool playBar;
|
||||
bool active;
|
||||
float vol;
|
||||
|
||||
int playPoint, endPoint;
|
||||
float barSample[44100];
|
||||
|
|
Loading…
Add table
Reference in a new issue