2008-02-14 06:47:12 +01:00
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* Copyright (C) 2008 Jonathan Moore Liles */
|
|
|
|
/* */
|
|
|
|
/* This program is free software; you can redistribute it and/or modify it */
|
|
|
|
/* under the terms of the GNU General Public License as published by the */
|
|
|
|
/* Free Software Foundation; either version 2 of the License, or (at your */
|
|
|
|
/* option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* This program is distributed in the hope that it will be useful, but WITHOUT */
|
|
|
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
|
|
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
|
|
|
|
/* more details. */
|
|
|
|
/* */
|
|
|
|
/* You should have received a copy of the GNU General Public License along */
|
|
|
|
/* with This program; see the file COPYING. If not,write to the Free Software */
|
|
|
|
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Window.H>
|
2008-02-16 05:23:58 +01:00
|
|
|
#include <FL/Fl_Double_Window.H>
|
2008-02-14 06:47:12 +01:00
|
|
|
#include <FL/Fl_Scroll.H>
|
2008-02-20 07:11:33 +01:00
|
|
|
#include <FL/Fl_Scrollbar.H>
|
2008-02-14 08:40:47 +01:00
|
|
|
#include <FL/Fl_Pack.H>
|
|
|
|
#include <FL/Fl_Group.H>
|
2008-02-17 00:12:23 +01:00
|
|
|
#include <FL/Fl_Slider.H>
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-20 06:57:14 +01:00
|
|
|
// #include "Waveform.H"
|
2008-02-14 08:40:47 +01:00
|
|
|
#include "Region.H"
|
2008-02-14 06:47:12 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-02-16 04:50:16 +01:00
|
|
|
#include "Track.H"
|
2008-02-21 07:39:00 +01:00
|
|
|
#include "Audio_Track.H"
|
2008-02-16 08:21:15 +01:00
|
|
|
#include "Timeline.H"
|
2008-02-16 04:50:16 +01:00
|
|
|
|
2008-02-17 22:25:02 +01:00
|
|
|
#include "const.h"
|
|
|
|
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-16 08:21:15 +01:00
|
|
|
Timeline timeline;
|
|
|
|
|
2008-02-17 00:12:23 +01:00
|
|
|
void
|
|
|
|
cb_zoom ( Fl_Widget *w, void *v )
|
|
|
|
{
|
|
|
|
timeline.fpp = ((Fl_Slider*)w)->value();
|
2008-02-17 10:00:38 +01:00
|
|
|
|
|
|
|
|
2008-02-20 06:57:14 +01:00
|
|
|
/* for ( int i = timeline.tracks->children(); i-- ; ) */
|
|
|
|
/* { */
|
|
|
|
/* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
|
|
|
|
/* for ( int j = track->children(); j-- ; ) */
|
|
|
|
/* ((Region*)(track->child( j )))->resize(); */
|
|
|
|
/* } */
|
2008-02-17 10:00:38 +01:00
|
|
|
|
2008-02-20 08:24:56 +01:00
|
|
|
|
2008-02-17 00:12:23 +01:00
|
|
|
timeline.scroll->redraw();
|
2008-02-17 10:00:38 +01:00
|
|
|
|
2008-02-17 22:25:02 +01:00
|
|
|
if ( timeline.fpp < FRAMES_PER_PEAK )
|
|
|
|
w->selection_color( FL_RED );
|
|
|
|
else
|
|
|
|
w->selection_color( FL_GRAY );
|
|
|
|
|
2008-02-17 10:00:38 +01:00
|
|
|
printf( "%f\n", timeline.fpp );
|
2008-02-17 00:12:23 +01:00
|
|
|
}
|
|
|
|
|
2008-02-20 07:11:33 +01:00
|
|
|
void
|
|
|
|
cb_scroll ( Fl_Widget *w, void *v )
|
|
|
|
{
|
2008-02-20 08:08:36 +01:00
|
|
|
timeline.xoffset = ((Fl_Slider*)w)->value();
|
|
|
|
// timeline.tracks->redraw();
|
2008-02-20 07:11:33 +01:00
|
|
|
timeline.scroll->redraw();
|
2008-02-20 08:08:36 +01:00
|
|
|
|
|
|
|
printf( "%lu\n", timeline.xoffset );
|
|
|
|
|
2008-02-20 08:24:56 +01:00
|
|
|
for ( int i = timeline.tracks->children(); i-- ; )
|
|
|
|
{
|
|
|
|
Fl_Group *track = (Fl_Group*)timeline.tracks->child( i );
|
|
|
|
track->damage( FL_DAMAGE_SCROLL );
|
|
|
|
}
|
|
|
|
|
2008-02-20 07:11:33 +01:00
|
|
|
/* /\* for ( int j = track->children(); j-- ; ) *\/ */
|
|
|
|
/* /\* ((Region*)(track->child( j )))->resize(); *\/ */
|
|
|
|
/* /\* } *\/ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-14 06:47:12 +01:00
|
|
|
int
|
|
|
|
main ( int argc, char **argv )
|
|
|
|
{
|
|
|
|
|
2008-02-16 05:23:58 +01:00
|
|
|
Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-20 07:11:33 +01:00
|
|
|
timeline.scroll = new Fl_Scroll( 0, 24, 800, 600 - (24 * 2) );
|
2008-02-20 06:57:14 +01:00
|
|
|
timeline.scroll->type( Fl_Scroll::VERTICAL );
|
2008-02-17 03:36:17 +01:00
|
|
|
timeline.fpp = 256;
|
2008-02-20 13:45:02 +01:00
|
|
|
timeline._beats_per_minute = 120;
|
2008-02-17 04:32:31 +01:00
|
|
|
|
2008-02-20 16:43:14 +01:00
|
|
|
|
|
|
|
timeline.beats_per_minute( 0, 120 );
|
|
|
|
timeline.beats_per_minute( 48000, 250 );
|
|
|
|
timeline.beats_per_minute( 48000 * 4, 60 );
|
|
|
|
|
|
|
|
|
2008-02-17 04:32:31 +01:00
|
|
|
timeline.sample_rate = 44100;
|
|
|
|
|
2008-02-20 06:57:14 +01:00
|
|
|
timeline.tracks = new Fl_Pack( 0, 0, 800, 5000 );
|
2008-02-17 10:00:38 +01:00
|
|
|
timeline.tracks->type( Fl_Pack::VERTICAL );
|
2008-02-19 07:22:42 +01:00
|
|
|
timeline.tracks->spacing( 20 );
|
2008-02-16 04:50:16 +01:00
|
|
|
|
2008-02-16 05:23:58 +01:00
|
|
|
Fl::get_system_colors();
|
|
|
|
Fl::scheme( "plastic" );
|
2008-02-16 04:50:16 +01:00
|
|
|
|
|
|
|
// Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 );
|
|
|
|
|
2008-02-21 02:51:40 +01:00
|
|
|
{
|
2008-02-21 07:02:43 +01:00
|
|
|
Track *tempo_track = new Track( 100, 0, 800, 24 );
|
2008-02-21 02:51:40 +01:00
|
|
|
|
|
|
|
tempo_track->label( "tempo map" );
|
2008-02-21 04:40:20 +01:00
|
|
|
tempo_track->add( new Tempo_Point( 0, 120 ) );
|
2008-02-21 02:51:40 +01:00
|
|
|
|
|
|
|
tempo_track->add( new Tempo_Point( 56000, 250 ) );
|
|
|
|
|
|
|
|
tempo_track->end();
|
|
|
|
}
|
|
|
|
|
2008-02-21 07:39:00 +01:00
|
|
|
Track *track1 = new Audio_Track( 40, 0, 800, 100 );
|
2008-02-14 08:40:47 +01:00
|
|
|
|
|
|
|
// pack->type( Fl_Pack::VERTICAL );
|
2008-02-16 04:50:16 +01:00
|
|
|
// pack->box( FL_DOWN_BOX );
|
2008-02-14 08:40:47 +01:00
|
|
|
|
2008-02-17 00:12:23 +01:00
|
|
|
// Region *wave = new Region( 0, 0, 5000, 100, "foo" );
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-18 04:37:26 +01:00
|
|
|
Region *wave = new Region( Clip::from_file( "streambass8.wav" ) );
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-17 10:00:38 +01:00
|
|
|
// wave->resize( 0, 0, 500, 100 );
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-19 07:22:42 +01:00
|
|
|
wave->offset( 1024 );
|
2008-02-20 06:57:14 +01:00
|
|
|
wave->end( 3000 );
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-20 06:57:14 +01:00
|
|
|
/* wave->color( FL_CYAN ); */
|
|
|
|
/* wave->selection_color( fl_darker( FL_GRAY ) ); */
|
|
|
|
/* wave->selection_color( FL_GREEN ); */
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-16 04:50:16 +01:00
|
|
|
track1->add( wave );
|
|
|
|
|
2008-02-20 06:57:14 +01:00
|
|
|
Region *wave3 = new Region( *wave );
|
|
|
|
wave3->offset( 4000 );
|
|
|
|
track1->add( wave3 );
|
|
|
|
|
2008-02-16 04:50:16 +01:00
|
|
|
track1->end();
|
|
|
|
|
2008-02-21 07:39:00 +01:00
|
|
|
Track *track2 = new Audio_Track( 40, 0, 5000, 100 );
|
2008-02-16 04:50:16 +01:00
|
|
|
|
2008-02-16 08:46:43 +01:00
|
|
|
// Region *wave2 = new Region( 0, 0, 350, 100, "bar" );
|
|
|
|
|
|
|
|
Region *wave2 = new Region( *wave );
|
2008-02-16 04:50:16 +01:00
|
|
|
|
2008-02-16 08:59:50 +01:00
|
|
|
/* wave2->peaks( peaks ); */
|
|
|
|
/* wave2->start( 300 ); */
|
|
|
|
/* wave2->end( len ); */
|
2008-02-16 04:50:16 +01:00
|
|
|
|
|
|
|
track2->add( wave2 );
|
|
|
|
|
2008-02-21 02:51:40 +01:00
|
|
|
|
2008-02-16 04:50:16 +01:00
|
|
|
track2->end();
|
|
|
|
|
|
|
|
track1->next( track2 );
|
|
|
|
track2->prev( track1 );
|
2008-02-14 08:40:47 +01:00
|
|
|
|
2008-02-17 10:00:38 +01:00
|
|
|
timeline.tracks->end();
|
2008-02-16 08:21:15 +01:00
|
|
|
timeline.scroll->end();
|
2008-02-14 06:47:12 +01:00
|
|
|
|
2008-02-17 00:12:23 +01:00
|
|
|
Fl_Slider *zoom_slider = new Fl_Slider( 0, 0, 800, 24 );
|
2008-02-18 04:37:26 +01:00
|
|
|
zoom_slider->type( FL_HOR_SLIDER );
|
2008-02-17 00:12:23 +01:00
|
|
|
zoom_slider->callback( cb_zoom, 0 );
|
2008-02-17 22:25:02 +01:00
|
|
|
zoom_slider->range( 2, 4096 );
|
2008-02-17 10:00:38 +01:00
|
|
|
zoom_slider->step( 1 );
|
2008-02-17 01:35:53 +01:00
|
|
|
zoom_slider->value( 256 );
|
2008-02-17 00:12:23 +01:00
|
|
|
|
2008-02-20 07:11:33 +01:00
|
|
|
timeline.scrollbar = new Fl_Scrollbar( 0, 600 - 24, 800, 24 );
|
2008-02-20 08:08:36 +01:00
|
|
|
timeline.scrollbar->range( 0, 48000 * 2 );
|
2008-02-20 07:11:33 +01:00
|
|
|
timeline.scrollbar->type( 1 );
|
|
|
|
timeline.scrollbar->step( 1 );
|
|
|
|
timeline.scrollbar->callback( cb_scroll, 0 );
|
|
|
|
|
2008-02-14 06:47:12 +01:00
|
|
|
main_window->end();
|
|
|
|
main_window->show();
|
|
|
|
|
2008-02-20 06:57:14 +01:00
|
|
|
/* wave->redraw(); */
|
2008-02-14 06:47:12 +01:00
|
|
|
|
|
|
|
Fl::run();
|
|
|
|
}
|