2013-10-12 00:21:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include "gaudioeditor.hxx"
|
|
|
|
|
2013-10-12 02:31:56 +02:00
|
|
|
#include <sstream>
|
|
|
|
|
2013-10-12 00:21:56 +02:00
|
|
|
#include "config.hxx"
|
|
|
|
|
|
|
|
#include "audiobuffer.hxx"
|
|
|
|
|
2013-10-12 01:06:15 +02:00
|
|
|
#include "avtk/waveform.h"
|
2013-10-12 00:21:56 +02:00
|
|
|
#include "avtk/avtk_button.h"
|
|
|
|
|
2013-10-12 01:06:15 +02:00
|
|
|
|
2013-10-12 02:31:56 +02:00
|
|
|
void oneCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 1 ); }
|
|
|
|
void twoCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 2 ); }
|
|
|
|
void fourCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 4 ); }
|
|
|
|
void eightCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 8 ); }
|
|
|
|
void sixteenCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 16); }
|
|
|
|
void thirtyTwoCB(Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 32); }
|
|
|
|
void sixtyfourCB(Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 64); }
|
|
|
|
|
|
|
|
void cancelCB(Fl_Widget*,void* data)
|
|
|
|
{
|
|
|
|
printf("button, beats = 4\n");
|
|
|
|
AudioEditor* ae = (AudioEditor*) data;
|
|
|
|
ae->setBeatsAndQuit( -1 );
|
|
|
|
}
|
|
|
|
|
2013-10-12 00:21:56 +02:00
|
|
|
AudioEditor::AudioEditor()
|
|
|
|
{
|
2013-10-12 14:19:37 +02:00
|
|
|
window = new Fl_Double_Window(460,200,"Audio Editor : Beats?");
|
2013-10-12 01:06:15 +02:00
|
|
|
waveform = new Avtk::Waveform(5, 5, 450, 150, "Waveform");
|
2013-10-12 02:31:56 +02:00
|
|
|
cancel = new Avtk::Button(360, 160, 80,30, "Cancel");
|
|
|
|
|
|
|
|
const char* names[] = {
|
|
|
|
"1","2","4","8","16","32","64"
|
|
|
|
};
|
|
|
|
|
|
|
|
for(int i = 0; i < 7; i++)
|
|
|
|
{
|
|
|
|
stringstream s;
|
|
|
|
s << i;
|
|
|
|
beatButtons[i] = new Avtk::Button(5 + i * 50, 160, 40,30, strdup(names[i]) );
|
|
|
|
}
|
2013-10-12 00:21:56 +02:00
|
|
|
window->end();
|
2013-10-12 02:31:56 +02:00
|
|
|
|
|
|
|
beatButtons[0]->callback( oneCB , this);
|
|
|
|
beatButtons[1]->callback( twoCB , this);
|
|
|
|
beatButtons[2]->callback( fourCB , this);
|
|
|
|
beatButtons[3]->callback( eightCB , this);
|
|
|
|
beatButtons[4]->callback( sixteenCB , this);
|
|
|
|
beatButtons[5]->callback( thirtyTwoCB, this);
|
|
|
|
beatButtons[6]->callback( sixtyfourCB, this);
|
|
|
|
|
|
|
|
cancel->callback( cancelCB, this );
|
2013-10-12 00:21:56 +02:00
|
|
|
}
|
|
|
|
|
2013-10-12 01:06:15 +02:00
|
|
|
void AudioEditor::show( AudioBuffer* buf, bool modal )
|
2013-10-12 00:21:56 +02:00
|
|
|
{
|
|
|
|
ab = buf;
|
|
|
|
|
|
|
|
if ( !ab )
|
|
|
|
{
|
|
|
|
LUPPP_WARN("called with ab == 0");
|
2013-10-12 01:06:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<float>& tmp = ab->getData();
|
|
|
|
waveform->setData( &tmp[0], tmp.size() );
|
2013-10-12 00:21:56 +02:00
|
|
|
}
|
|
|
|
|
2013-10-12 01:06:15 +02:00
|
|
|
window->set_modal();
|
|
|
|
|
2013-10-12 00:21:56 +02:00
|
|
|
window->show();
|
|
|
|
}
|
|
|
|
|
2013-11-09 22:50:21 +01:00
|
|
|
void AudioEditor::hide()
|
|
|
|
{
|
|
|
|
window->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-12 02:31:56 +02:00
|
|
|
void AudioEditor::setBeatsAndQuit(int beats)
|
|
|
|
{
|
|
|
|
ab->setBeats(beats);
|
|
|
|
window->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
AudioBuffer* AudioEditor::getAudioBuffer()
|
|
|
|
{
|
|
|
|
return ab;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2013-10-12 01:06:15 +02:00
|
|
|
bool AudioEditor::shown()
|
|
|
|
{
|
|
|
|
return window->shown();
|
|
|
|
}
|
2013-10-12 00:21:56 +02:00
|
|
|
|
|
|
|
AudioEditor::~AudioEditor()
|
|
|
|
{
|
|
|
|
delete window;
|
|
|
|
}
|