non/main.C

86 lines
2.5 KiB
C

/*******************************************************************************/
/* 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>
#include <FL/Fl_Scroll.H>
#include "Waveform.H"
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
Fl_Color velocity_colors[128];
void
init_colors ( void )
{
for ( int i = 128; i--; )
velocity_colors[i] = fl_rgb_color( 23, 255 - i * 2, 32 );
}
int
main ( int argc, char **argv )
{
init_colors();
Fl_Window *main_window = new Fl_Window( 0, 0, 800, 600 );
Fl_Scroll *scroll = new Fl_Scroll( 0, 0, 800, 600 );
Waveform *wave = new Waveform( 0, 0, 5000, 100, "foo" );
FILE *fp;
fp = fopen( "peaks", "r" );
struct stat st;
fstat( fileno( fp ), &st );
size_t len = st.st_size;
float *peaks = new float[ len / sizeof( float ) ];
fread( peaks, len, 1, fp );
wave->peaks( peaks );
wave->start( 0 );
wave->end( len );
wave->color( FL_CYAN );
wave->selection_color( fl_darker( FL_GRAY ) );
wave->selection_color( FL_GREEN );
scroll->end();
main_window->end();
main_window->show();
wave->redraw();
Fl::run();
}