dslinux/user/pixil/apps/fltk/mp3/frontend Fl_Eq.cxx Makefile Mp3_Browser.cc Mp3_Browser.h Mp3_Node.cc Mp3_Node.h callbacks.cc callbacks.h comm.cc comm.h dsp.h dsp_feedback.cc dsp_feedback.h fft.cc fft.h flnxDouble_Blink_Window.H fltksplay.cc fspl_panel.cc fspl_panel.h mp3_button.cc mp3buttons.h mp3utils.cc mp3utils.h xplay.cc xplay.h
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:24:26 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/apps/fltk/mp3/frontend
In directory antilope:/tmp/cvs-serv11916/apps/fltk/mp3/frontend
Added Files:
Fl_Eq.cxx Makefile Mp3_Browser.cc Mp3_Browser.h Mp3_Node.cc
Mp3_Node.h callbacks.cc callbacks.h comm.cc comm.h dsp.h
dsp_feedback.cc dsp_feedback.h fft.cc fft.h
flnxDouble_Blink_Window.H fltksplay.cc fspl_panel.cc
fspl_panel.h mp3_button.cc mp3buttons.h mp3utils.cc mp3utils.h
xplay.cc xplay.h
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: mp3utils.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef MP3UTILS_H
#define MP3UTILS_H
////////////////////////////////////////////////////////////////////////////////
// MP3 Utitlity Class
////////////////////////////////////////////////////////////////////////////////
class Mp3Utils
{
public:
Mp3Utils()
{
}
void strman(char *str, int max);
void stripfilename(char *dtr, char *str, int max);
void parseID3(char *path, char *title);
};
#endif // MP3UTILS_H
--- NEW FILE: fspl_panel.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef FSPL_PANEL_H
#define FSPL_PANEL_H
#include <FL/Fl.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Timer.H>
#include <FL/Fl_Hold_Browser.H>
#include <nxapp.h>
#include <nxwindow.h>
#include <nxdb.h>
#include <nxbutton.h>
#include <nxwindow.h>
#include <nxscroll.h>
#include <nxvalueslider.h>
#include <nxmenubutton.h>
#include <nxbox.h>
//#include <iostream.h>
#include <string.h>
#include "Mp3_Browser.h"
#include "comm.h"
#include "mp3utils.h"
#define WIDTH 240
#define HEIGHT 290
#define EQ_X 30
#define EQ_Y 5
#define MAX_NAME_LENGTH 1024
#define APP_NAME "MP3 Player"
enum mp3_type
{
MP3_FORWARD = 0,
MP3_PLAY = 1,
MP3_STOP = 2,
MP3_BACK = 3,
MP3_PAUSE = 4
};
extern class_musics musics;
extern class_music music;
class mp3_button:public NxButton
{
int type_;
public:
mp3_button(int x, int y, int w, int h, int type);
~mp3_button();
void type(int t)
{
type_ = t;
}
virtual void draw();
};
class fspl_panel:public NxApp
{
private:
struct
{
char name[1024];
char artist[1024];
char album[1024];
char year[1024];
char comment[1024];
int length;
}
info;
static char *titles[255];
static char *playList[255];
static char *paths[255];
static Mp3_Node *playNode;
static int nodes;
static int listNum;
static int menuValue;
void free_paths();
void free_titles();
void free_play_list();
int get_song_length(char *filename);
void get_song_info(char *filename);
void get_volume();
void get_files_from_list(char *file);
void get_files(char *dir);
void reload_browser(char *file);
void load_browser();
void clear_browser();
public:
fspl_panel(char *app);
~fspl_panel();
void MakePlayWindow();
static int curPlaying;
static int selPlay;
static int doubleClicked;
static int stopPressed;
static int pausePressed;
static char *defaultMusicPath;
Fl_Pixmap *speakerSoft;
Fl_Pixmap *speakerLoud;
static NxWindow *window;
static NxPimWindow *playWindow;
static Mp3_Browser *mp3Browser;
static Fl_Pixmap *musicNote;
static NxScroll *musicScroll;
static mp3_button *backButton;
static mp3_button *forwardButton;
static mp3_button *stopButton;
static mp3_button *pauseButton;
static mp3_button *playButton;
static NxSlider *volumeSlider;
static NxMenuButton *playListMenu;
// Callbacks
static void menu_callback(Fl_Widget * w, void *o);
static void pause_callback(Fl_Widget *, void *);
static void stop_callback(Fl_Widget * o = 0, void *vp = 0);
static void play_callback(Fl_Widget * o = 0, void *vp = 0);
static void back_callback(Fl_Widget *, void *);
static void forward_callback(Fl_Widget * w = 0, void *o = 0);
static void volume_callback(Fl_Widget *, void *);
static void sspectra_callback(Fl_Widget *, void *);
static void progress_callback(Fl_Widget * o, void *);
static void timer_callback(void *);
static void normal_callback(Fl_Widget *, void *);
static void add_callback(Fl_Widget *, void *);
static void fileok_callback(Fl_Widget * o = 0, void *vp = 0);
static void filecan_callback(Fl_Widget *, void *);
static void addall_callback(Fl_Widget *, void *);
static void del_callback(Fl_Widget *, void *);
static void delall_callback(Fl_Widget *, void *);
static void hideshowpl_callback(Fl_Widget *, void *);
static void browser_callback(Fl_Widget *, void *);
static void http_callback(Fl_Widget *, void *);
// Strip codes of browser text string
void StripFormatCodes(char *title);
// ugly hack because apparently we can't write into xplay's memory space
char kbps_title[64];
char khz_title[64];
void SetDefaultMusicPath(char *dmp)
{
strcpy(defaultMusicPath, dmp);
strcat(defaultMusicPath, "/");
}
};
#endif // FSPL_PANEL_H
--- NEW FILE: xplay.cc ---
/* Sound Player
Portions Copyright (C) 2002, Century Embedded Technologies
Original Copyright (C) 1997 by Woo-jae Jung
*/
#include <pixil_config.h>
#include <pthread.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <iostream.h>
#include "xplay.h"
#include "comm.h"
char *nullstring = "";
char *stopstring = "Stop";
char *nonestring = "None";
/* common.cc playlist functions
extern char** splay_list;
extern int splay_listsize;
extern bool splay_shuffleflag;
extern bool splay_repeatflag;
*/
pthread_mutex_t startuplock;
extern class_musics musics;
extern class_music music;
/*******************/
/* Frame functions */
/*******************/
int
getslidernumber(int framenumber, int maxframe)
{
register unsigned int a;
a = MAXFRAMESLIDER * (unsigned int) framenumber;
a /= (unsigned int) maxframe;
return (int) a;
}
static int
getframenumber(int slidernum, int maxframe)
{
register unsigned int a;
a = (unsigned int) maxframe *(unsigned int) slidernum;
a /= (unsigned int) MAXFRAMESLIDER;
return (int) a;
}
static int
adjustframe(int slider, int maxframe)
{
int f, s;
if (maxframe == 0)
return 0;
f = getframenumber(slider, maxframe);
for (;;) {
s = getslidernumber(f, maxframe);
if (s >= slider)
break;
f++;
}
return f;
}
/*************************************/
/* Funcitions playing MPEG/Wave file */
/*************************************/
static void
seterrorcode(int errcode)
{
musics.errorcode = errcode;
musics.errorflag = true;
music_done();
}
static void
xplaympeg(char *filename, Soundinputstream * loader, Rawplayer * player)
{
// cout << "xplaympeg()\n";
Mpegtoraw *server;
bool threadflag = 0;
int panelupdate = 0;
int pcmperframe, frequency;
int updatedelay;
// Server
if ((server = new Mpegtoraw(loader, player)) == NULL) {
seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
return;
}
server->initialize(filename);
// server->setforcetomono(splay_forcetomonoflag);
// server->setdownfrequency(splay_downfrequency);
if (threadflag) {
server->makethreadedplayer(50);
}
// Setsongname (server->getname());
// Setsongmusican(server->getartist());
music.quit = music.pause = music.setframeflag = false;
musics.feedback->Hz = 440;
musics.feedback->SR = 44100;
SetDsp(FEEDBACK);
if (!server->run(-1)) // Initialize MPEG player
{
musics.Setcurrentmpegstatus(0, 0, 0, 0, "Srv Lives");
if (threadflag)
server->freethreadedplayer();
seterrorcode(server->geterrorcode());
// Paneldone();
delete server;
return;
}
pcmperframe = server->getpcmperframe();
frequency = server->getfrequency();
updatedelay = frequency / pcmperframe / 6;
if (getquotaflag()) {
//int q=server->getfrequency()*(server->isstereo()+1);
/*
if(!splay_forcetomonoflag)q<<=1;
q>>=1;
*/
player->setquota(1024);
}
char title[1024];
strcpy(title, "Error locating title");
{
ID3 data;
parseID3(loader, &data);
if (0 == strcmp("", data.songname)) {
strcpy(title, filename);
} else {
sprintf(title, "%s - %s", data.artist, data.songname);
}
}
musics.Setcurrentmpegstatus(server->getversion(), server->getlayer(),
server->getfrequency(), server->getbitrate(),
title);
/*
server->getcrccheck(), server->isstereo(),
server->getforcetomono(),server->getdownfrequency());
Unlockframeslider();
*/
for (;;) {
SetDsp(FEEDBACK);
if (GetDsp()) {
SetDspData((void *) (server->GetRawData()));
}
if (music.setframeflag) {
int a;
music.setframeflag = false;
panelupdate = updatedelay;
a = adjustframe(music.setframenumber, server->gettotalframe());
server->setframe(a);
/*
Unlockframeslider();
Setframestatus(server->getcurrentframe(),
0,
pcmperframe,frequency);
*/
musics.pcmperframe = server->getpcmperframe();
musics.currentframe = server->getcurrentframe();
musics.maxframe = server->gettotalframe();
if (musics.volumeflag != 0) {
// Setvolume(musics.newvolume);
musics.volumeflag = 0;
}
}
if (music.pause) // When pause set,
{
if (threadflag) {
server->pausethreadedplayer();
server->setframe(server->getcurrentframe());
}
server->clearbuffer();
while (music.pause)
if (threadflag && (server->getframesaved() < (49))) {
server->run(1);
panelupdate = updatedelay;
} else if (music.setframeflag) {
music.setframeflag = false;
server->setframe(adjustframe(music.setframenumber,
server->gettotalframe()));
/*
Setframestatus(server->getcurrentframe(),
0,
pcmperframe,frequency);
Unlockframeslider();
*/
musics.pcmperframe = server->getpcmperframe();
musics.currentframe = server->getcurrentframe();
musics.maxframe = server->gettotalframe();
if (musics.volumeflag != 0) {
// Setvolume(musics.newvolume);
musics.volumeflag = 0;
}
} else
usleep(100);
if (music.setframeflag) {
panelupdate = -1;
music.setframeflag = false;
server->setframe(adjustframe(music.setframenumber,
server->gettotalframe()));
}
if (threadflag)
server->unpausethreadedplayer();
}
if (panelupdate < 0) {
/*
Setframestatus(server->getcurrentframe(),
server->gettotalframe(),
pcmperframe,frequency);
*/
musics.pcmperframe = server->getpcmperframe();
musics.currentframe = server->getcurrentframe();
musics.maxframe = server->gettotalframe();
panelupdate = updatedelay;
if (musics.volumeflag != 0) {
// Setvolume(musics.newvolume);
musics.volumeflag = 0;
}
} else
panelupdate--;
if (music.quit) {
if (threadflag) {
server->stopthreadedplayer();
while (server->existthread())
usleep(10);
}
player->abort();
player->resetsoundtype();
break;
}
if (!server->run(5)) {
if (!threadflag) {
music_done();
break;
}
if (server->getframesaved() == 0) {
music_done();
break;
}
usleep(100);
}
}
if (threadflag)
server->freethreadedplayer();
#ifdef CONFIG_DEBUG
cout << "\tdone\n";
#endif
// Paneldone();
delete server;
return;
}
/*
static char *stripfilename(char *str)
{
static char songname[30+1];
char *ss;
int p=0,s=0;
for(;str[p];p++)
if(str[p]=='/')
{
p++;
s=p;
}
ss=str+s;
for(p=0;p<30 && ss[p];p++)songname[p]=ss[p];
songname[p]=0;
return songname;
}
#define FRAMESIZE (4096)
static void xplaywave(char *filename,Soundinputstream *loader,Rawplayer *player)
{
Wavetoraw *server;
int frequency;
// Server
if((server=new Wavetoraw(loader,player))==NULL)
{
seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
return;
}
server->initialize();
// server->setforcetomono(splay_forcetomonoflag);
// Setsongname(stripfilename(filename));
music.pause=music.quit=music.setframeflag=false;
// Unlockframeslider();
if(!server->run()) // Initialize Wave player
{
// Setcurrentwavestatus(0,0,0);
seterrorcode(server->geterrorcode());
// Paneldone();
delete server;
return;
}
{
int q=server->getfrequency()*(server->isstereo()+1);
//if(server->getsamplesize()==16)
//{
// if(!splay_forcetomonoflag)q<<=1;
//}
//q>>=1;
player->setquota(q);
}
frequency=server->getfrequency();
// Setcurrentwavestatus(server->getsamplesize(),
// frequency,
// server->isstereo());
for(;;)
{
if(music.pause)
{
player->abort();player->resetsoundtype();
while(music.pause)
{
if(music.setframeflag)
{
music.setframeflag=false;
//Setframestatus(server->getcurrentpoint()/FRAMESIZE,
// 0,
// FRAMESIZE,frequency);
server->setcurrentpoint(FRAMESIZE*
adjustframe(music.setframenumber,
server->gettotallength()/FRAMESIZE));
// Unlockframeslider();
}
usleep(100);
}
}
if(music.setframeflag)
{
player->abort();player->resetsoundtype();
music.setframeflag=false;
server->setcurrentpoint(FRAMESIZE*
adjustframe(music.setframenumber,
server->gettotallength()/FRAMESIZE));
//Unlockframeslider();
//Setframestatus(server->getcurrentpoint()/FRAMESIZE,
// 0,
// FRAMESIZE,frequency);
}
else
{
//Setframestatus(server->getcurrentpoint()/FRAMESIZE,
// server->gettotallength()/FRAMESIZE,
// FRAMESIZE,frequency);
}
if(music.quit)
{
player->getprocessed();
player->abort();player->resetsoundtype();
break;
}
if(!server->run())
{
music_done();
break;
}
}
// Paneldone();
delete server;
return;
}
*/
static void
xplayfile(char *filename)
{
char *device = Rawplayer::defaultdevice;
Rawplayer *player;
Soundinputstream *loader;
// Loader
{
int err;
if (strstr(filename, "http://")) {
loader = new Soundinputstreamfromhttp();
if ((loader->open(filename)) == false) {
seterrorcode(err);
return;
}
} else {
if ((loader = Soundinputstream::hopen(filename, &err)) == NULL) {
seterrorcode(err);
return;
}
}
}
// Player
if (device == NULL)
device = Rawplayer::defaultdevice;
if (device[0] != '/')
device = Rawplayer::defaultdevice;
player = new Rawplayer;
if (player == NULL) {
seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
return;
}
if (!player->initialize(device)) {
seterrorcode(player->geterrorcode());
return;
}
// Select which
// if(strstr(filename,".mp") || strstr(filename,".MP"))
xplaympeg(filename, loader, player);
// else
// xplaywave(filename,loader,player);
// Clearcurrentstatus();
// Clean up
delete loader;
delete player;
}
/**********/
/* Player */
/**********/
static void
xplay()
{
bool updateflag = true; // Control music_stop and music_move;
// printf("Welcome to the thread!\n");
musics.restart = true;
musics.errorflag = false;
pthread_mutex_init(&musics.movelock, NULL);
for (;;) {
if (musics.restart) {
#ifdef CONFIG_DEBUG
printf("THREAD: In restart\n");
#endif
musics.stop = true;
musics.restart = false;
musics.currentrun = 0;
musics.move = 0;
updateflag = true;
#ifdef CONFIG_DEBUG
printf("THREAD: Out restart\n");
#endif
}
if (musics.errorflag) {
#ifdef CONFIG_DEBUG
printf("THREAD: In errorflag\n");
#endif
musics.errorflag = false;
#ifdef CONFIG_DEBUG
printf("THREAD: Out errorflag\n");
#endif
}
if (musics.move != 0) {
#ifdef CONFIG_DEBUG
printf("THREAD: In move\n");
#endif
pthread_mutex_lock(&musics.movelock);
#ifdef CONFIG_DEBUG
printf("THREAD: In move pthread_mutex_lock\n");
#endif
musics.currentrun += musics.move;
if (musics.currentrun >= 1) {
musics.restart = true;
musics.currentrun = 1;
musics.stop = true;
}
if (musics.currentrun < 0) {
musics.currentrun = 0;
}
musics.move = 0;
#ifdef CONFIG_DEBUG
printf("THREAD: In move about to pthread_mutex_unlock\n");
#endif
pthread_mutex_unlock(&musics.movelock);
updateflag = true;
#ifdef CONFIG_DEBUG
printf("THREAD: Out move\n");
#endif
}
if (updateflag) {
//char *str;
#ifdef CONFIG_DEBUG
printf("THREAD: In updateflag=false\n");
#endif
updateflag = false;
#ifdef CONFIG_DEBUG
printf("THREAD: Out updateflag=false\n");
printf("musics.stop value: %d\n", musics.stop);
#endif
}
if (musics.stop) {
usleep(500); // Don't play
} else {
#ifdef CONFIG_DEBUG
printf("THREAD: In play\n");
#endif
if (musics.currentrun < 1) {
musics.tracksplayed++;
char *fname = 0;
#ifdef CONFIG_DEBUG
printf("THREAD: In play, before GetPlayList()...\n");
#endif
fname = GetPlayList();
#ifdef CONFIG_DEBUG
printf("THREAD: In play, Playing file %s\n", fname);
#endif
xplayfile(fname);
updateflag = true;
#ifdef CONFIG_DEBUG
printf("THREAD: Out play\n");
#endif
} else {
#ifdef CONFIG_DEBUG
printf("THREAD: In music.restart=true\n");
#endif
musics.restart = true;
#ifdef CONFIG_DEBUG
printf("THREAD: Out music.restart=true\n");
#endif
}
}
}
}
void
Setframe(int frame)
{
music.setframenumber = frame;
music.setframeflag = true;
}
static bool quotaflag = false;
bool
getquotaflag(void)
{
return quotaflag;
}
void
setquotaflag(bool flag)
{
quotaflag = flag;
}
/*********************************/
/* Initialize and main functions */
/*********************************/
/*
inline void xinit(int& argc,char *argv[])
{
pthread_mutex_init(&startuplock,NULL);
pthread_mutex_lock(&startuplock);
// Getxarg(argc,argv);
}
*/
void *
_startup(void *)
{
pthread_mutex_lock(&startuplock);
musics.stop = true;
xplay();
return NULL;
}
/*
inline int xmain(void)
{
pthread_t th;
pthread_create(&th,NULL,_startup,NULL);
SetupPanel();
pthread_mutex_unlock(&startuplock);
return RunPanel();
}
*/
/***********************/
/* Command line player */
/***********************/
/*
inline void error(int n)
{
fprintf(stderr,"%s: %s\n",splay_progname,splay_Sounderrors[n-1]);
return;
}
*/
/*
int main(int argc,char *argv[])
{
int c;
splay_progname=argv[0];
xinit(argc,argv);
while((c=getopt(argc,argv,
"V2emrsvd:l:t:"
))>=0)
{
switch(c)
{
case 'V':printf("x%s %s\n",PACKAGE,VERSION);
return 0;
case '2':splay_downfrequency = 1;break;
case 'e':splay_exitwhendone =true;break;
case 'm':splay_forcetomonoflag=true;break;
case 'r':splay_repeatflag =true;break;
case 's':splay_shuffleflag =true;break;
case 'v':splay_verbose++; break;
case 'd':splay_devicename=optarg;break;
case 'l':if(splay_verbose)
fprintf(stderr,"List file : %s\n",optarg);
readlist(optarg);
break;
default:fprintf(stderr,"Bad argument.\n");
}
}
if(splay_listsize==0) // Make list by arguments
arglist(argc,argv,optind);
return xmain();
}
*/
--- NEW FILE: Mp3_Node.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef Mp3_Node_H
#define Mp3_Node_H
#include <Flek/Fl_Toggle_Node.H>
#include <stdio.h>
class Mp3_Node:public Fl_Toggle_Node
{
friend class Mp3_Browser;
public:
Mp3_Node(char *label = 0, char *time_label = 0, int can_open =
1, Fl_Pixmap * pixmap = 0, void *d =
0):Fl_Toggle_Node(label, can_open, pixmap, d)
{
if (!time_label)
time_label_ = strdup("--:--");
else
time_label_ = strdup(time_label);
}
char *time_label(void)
{
return time_label_;
}
void time_label(char *ptr)
{
if (time_label_)
delete time_label_;
time_label_ = strdup(ptr);
}
protected:
char *time_label_;
};
#endif
--- NEW FILE: Makefile ---
# apps/mp3/frontend/Makefile
TARGET_CXX=pixil-splay
OBJS= mp3_button.o mp3utils.o fltksplay.o fspl_panel.o \
comm.o xplay.o fft.o Mp3_Browser.o Mp3_Node.o Fl_Eq.o
LIBS=-L ../mpegsound -lmpeg -lpixil-pim
CFLAGS ?=
CFLAGS += -DPIXIL
ifeq ($(CONFIG_SYNC),y)
LIBS+=-lpixil-sync
endif
ifeq ($(CONFIG_PAR),y)
LIBS+=-lpar
endif
LIBS+=-lfltk -lflek
ifeq ($(CONFIG_NANOX),y)
LIBS+=-lnano-X
endif
ifeq ($(CONFIG_X11),y)
LIBS+=-lX11
endif
ifeq ($(CONFIG_COLOSSEUM),y)
LIBS+=-lipc
endif
ifeq ($(CONFIG_MP3_USE_PTHREAD),y)
CFLAGS += -DPTHREADEDMPEG
LIBS+=-lpthread
endif
INCLUDES=-I. -I../mpegsound/
include $(BASE_DIR)/Rules.make
--- NEW FILE: fft.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include <FL/n_x.h>
#ifndef _FFT_H_
#define _FFT_H_
#define FFT_BUFFER_SIZE_LOG 9
#define FFT_BUFFER_SIZE (1 << FFT_BUFFER_SIZE_LOG)
/* sound sample - should be an signed 16 bit value */
typedef short int sound_sample;
#define __cplusplus 1
#ifdef __cplusplus
extern "C"
{
#endif
/* FFT library */
typedef struct _struct_fft_state fft_state;
fft_state *fft_init(void);
void fft_perform(const sound_sample * input, int *output,
fft_state * state, int dataFrameSkip);
void fft_close(fft_state * state);
#ifdef __cplusplus
}
#endif
#endif /* _FFT_H_ */
--- NEW FILE: callbacks.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef CALLBACKS_H
#define CALLBACKS_H
#include <FL/Fl_Hold_Browser.H>
#include <FL/Fl_Button.H>
#include "fspl_panel.h"
#include "comm.h"
#include "mp3utils.h"
#define MAX_NAME_LENGTH 1024
#define DEFAULT_MUSIC_PATH "/MP3/"
fspl_panel *MainPanel;
extern class_musics musics;
extern class_music music;
Fl_Hold_Browser *plBrowser;
Fl_Button *plHideShow;
Fl_Button *plAdd;
Fl_Button *plAddAll;
Fl_Button *plDel;
Fl_Button *plDelAll;
Mp3Utils mp3;
int curPlaying = 0;
int stopPressed = 1;
extern "C"
{
void pause_callback(Fl_Widget *, void *);
void stop_callback(Fl_Widget * o = 0, void *vp = 0);
void play_callback(Fl_Widget * o = 0, void *vp = 0);
void back_callback(Fl_Widget *, void *);
void forward_callback(Fl_Widget *, void *);
void volume_callback(Fl_Widget *, void *);
void progress_callback(Fl_Widget * o, void *);
void timer_callback(void *);
void feedback_callback(Fl_Widget *, void *);
void normal_callback(Fl_Widget *, void *);
void add_callback(Fl_Widget *, void *);
void addall_callback(Fl_Widget *, void *);
void del_callback(Fl_Widget *, void *);
void delall_callback(Fl_Widget *, void *);
void hideshowpl_callback(Fl_Widget *, void *);
}
#endif // CALLBACKS_H
--- NEW FILE: Mp3_Browser.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include <stdio.h>
#include "Mp3_Browser.h"
#include <FL/fl_draw.H>
#include <nxapp.h>
Mp3_Browser::Mp3_Browser(int x, int y, int w, int h):
Fl_Toggle_Tree(x, y, w, h)
{
}
void
Mp3_Browser::draw_node(int depth, int cy, Fl_Toggle_Node * node)
{
Mp3_Node *tnode = (Mp3_Node *) node;
if (damage() == FL_DAMAGE_CHILD && !tnode->changed_ && damaged_ == 0)
return;
tnode->changed_ = 0;
if (tnode->selected_) {
fl_color(selection_color());
fl_rectf(x() + depth * 16 + pixmap_offset_, cy,
w() - depth * 16 - pixmap_offset_, height_(tnode) - 1);
fl_xyline(x(), cy - 1, x() + w(), cy - 1);
fl_xyline(x(), cy + height_(tnode) - 1, x() + w(),
cy + height_(tnode) - 1);
fl_xyline(x() + depth * 16 + pixmap_offset_, cy - 1,
x() + depth * 16 + pixmap_offset_, cy + height_(tnode) - 1);
} else {
fl_color(color());
fl_rectf(x() + depth * 16 + pixmap_offset_, cy,
w() - depth * 16 - pixmap_offset_, height_(tnode) - 1);
fl_color(selection_color());
fl_xyline(x(), cy - 1, x() + w(), cy - 1);
fl_xyline(x(), cy + height_(tnode) - 1, x() + w(),
cy + height_(tnode) - 1);
fl_xyline(x() + depth * 16 + pixmap_offset_, cy - 1,
x() + depth * 16 + pixmap_offset_, cy + height_(tnode) - 1);
}
fl_color(NxApp::Instance()->getGlobalColor(APP_FG));
if (tnode->selected_)
textcolor(selection_label_color());
// else
// textcolor(((Fl_Toggle_Node *)node)->color());
if (tnode->label_) {
int D = depth * 16 + label_offset_;
draw_label((Mp3_Node *) tnode, D, x() + depth * 16 + pixmap_offset_,
cy, w() - depth * 16 - pixmap_offset_, 16);
}
if (tnode->pixmap_) {
tnode->pixmap_->draw(x() + 2, cy + 2);
}
}
void
Mp3_Browser::draw_label(Mp3_Node * node, int indent, int x, int y, int w,
int h)
{
Fl_Font font = textfont();
Fl_Color lcol = textcolor();
Fl_Align align = (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CLIP);
int size = textsize();
char str[1024];
char time_str[255];
memset(str, 0, sizeof(str));
memset(time_str, 0, sizeof(time_str));
fl_font(font, size);
int time_width = (int) fl_width("MM:MM");
int label_width = w - time_width - 17;
int time_x = x + w - time_width - 12;
int dot_width = (int) fl_width("...");
int len = 0;
if (node->label_) {
int lw = (int) fl_width(node->label_);
if (lw > label_width) {
char temp_str[255];
len = strlen(node->label_);
strcpy(temp_str, node->label_);
while (lw + dot_width > label_width) {
memset(temp_str, 0, sizeof(temp_str));
strncpy(temp_str, node->label_, --len);
lw = (int) fl_width(temp_str);
}
strcat(temp_str, "...");
strcpy(node->label_, temp_str);
}
}
if (!active_r())
lcol = inactive(lcol);
fl_color(lcol);
fl_draw(node->label_, x + 5, y, w - indent, h + 1, align);
align = (Fl_Align) (FL_ALIGN_RIGHT | FL_ALIGN_CLIP);
fl_draw(node->time_label_, time_x, y, time_width, h + 1, align);
}
Mp3_Browser::~Mp3_Browser()
{
}
--- NEW FILE: dsp_feedback.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
// dsp_feedback.h
#ifndef DSP_FEEDBACK_H
#define DSP_FEEDBACK_H
#include "dsp.h"
#include "fft.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Eq.H>
#include <stdio.h>
#include <iostream.h>
// Server DSP plug-ins definitions
#define FEEDBACK 1
struct feedback_struct
{
int Hz;
int SR;
Fl_Window *parent;
};
class Dsp_Feedback:public Dsp
{
private:
feedback_struct * feedback;
int init;
static fft_state *state;
int tmp_out[257];
int dest[257];
short int sample[512];
float scale;
Fl_Eq *eq0;
Fl_Eq *eq1;
Fl_Eq *eq2;
Fl_Eq *eq3;
Fl_Eq *eq4;
Fl_Eq *eq5;
Fl_Eq *eq6;
Fl_Eq *eq7;
Fl_Eq *eq8;
Fl_Eq *eq9;
Fl_Eq *eq10;
Fl_Eq *eq11;
Fl_Eq *eq12;
Fl_Eq *eq13;
Fl_Eq *eq14;
int dataFrameSkip;
protected:
void FeedbackFilter(void *data);
void Init();
public:
Dsp_Feedback();
~Dsp_Feedback();
virtual void *ApplyDsp(void *data, int skip);
void SetArgs(void *args);
};
extern Dsp_Feedback *feedbackFilter;
#endif // DSP_FEEDBACK_H
--- NEW FILE: dsp.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef DSP_H
#define DSP_H
#include <math.h>
#define SSLIMIT 18
#define RAWDATASIZE (2*2*32*SSLIMIT)
class Dsp
{
protected:
short int *buffer;
int current;
public:
Dsp()
{
buffer = 0;
current = 0;
}
virtual ~ Dsp()
{
};
virtual void *ApplyDsp(void *data, int skip) = 0;
void SetDsp(int newDsp)
{
current = newDsp;
}
int GetDsp()
{
return current;
}
};
#endif // DSP_H
--- NEW FILE: flnxDouble_Blink_Window.H ---
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
class double_blink_window : public Fl_Double_Window {
void draw() {
cout << "parent: " << (void*)this << endl;
for ( int i=0; i < children(); i++ ) {
draw_child( *child(i) );
cout << "child: " << (void*)child(i) << endl;
}
}
public:
double_blink_window(int x, int y, int w, int h, const char *l=0)
: Fl_Double_Window(x,y,w,h,l) { resizable(this); }
double_blink_window(int w, int h, const char *l=0)
: Fl_Double_Window(w,h,l) { resizable(this); }
};
--- NEW FILE: fltksplay.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <pthread.h>
#include <unistd.h>
#include <iostream.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include "fspl_panel.h"
#include "xplay.h"
#define OPTIONS "p:fw:h:b:t:s:H"
int w_opt = 0;
int h_opt = 0;
char *args = NULL;
extern pthread_mutex_t startuplock;
int exit_flag = 0;
int
main(int argc, char **argv)
{
pthread_t th;
pthread_create(&th, NULL, _startup, NULL);
fspl_panel MainPanel(APP_NAME);
signed char c;
while ((c = getopt(argc, argv, OPTIONS)) != -1) {
switch (c) {
case 'p':
args = optarg;
struct stat dir;
if (stat(args, &dir) == 0) {
;
//MainPanel->SetDefaultMusicPath(args);
}
break;
case 'f':
if (args) {
int i = mkdir(args, 0700);
if (i == 0);
//MainPanel->SetDefaultMusicPath(args);
}
break;
case 'w':
w_opt = atoi(optarg);
break;
case 'h':
h_opt = atoi(optarg);
break;
case 'b':
break;
case 't':
//MainPanel.SetDefaultFFTTimer(atof(optarg));
break;
case 's':
//MainPanel->SetDefaultFFTSkip(atoi(optarg));
break;
case 'H':
cerr <<
"\n*************************************************************\n";
cerr <<
"* NAME *\n";
cerr <<
"*\tfltksplay - Microwindows/FLNX MP3 player. *\n";
cerr << "*\t\t *\n";
cerr <<
"* SYNOPSIS *\n";
cerr <<
"*\tfltksplay *\n";
cerr << "*\t\t -p = default music path *\n";
cerr << "*\t\t -f = force mkdir of default music path *\n";
cerr << "*\t\t -w = background image width *\n";
cerr << "*\t\t -h = background image height *\n";
cerr << "*\t\t -b = background image *\n";
cerr << "*\t\t -t = fft timer in seconds *\n";
cerr << "*\t\t -s = fft number of frames to skip *\n";
cerr << "*\t\t -H = help *\n";
cerr <<
"*************************************************************\n\n";
exit(1);
break;
} // switch
} // while
// Set width and Height.
usleep(500);
pthread_mutex_unlock(&startuplock);
return Fl::run();
}
--- NEW FILE: comm.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include <pixil_config.h>
#include "comm.h"
//#include <iostream.h>
#include <stdio.h>
class_musics::class_musics()
{
// initializations
volumeflag = 0;
newvolume = 0;
version = 2;
layer = 3;
bitrate = 0;
freq = 44100;
pcmperframe = 0;
currentframe = 0;
maxframe = 1;
strcpy(filename, "\0");
tracksplayed = 0;
strcpy(title, "\0");
strcpy(ch_bitrate, "\0");
strcpy(ch_freq, "\0");
song = new char[1024];
feedback = new feedback_struct;
playlist = new playlist_struct[255];
for (int i = 0; i < 255; i++) {
playlist[i].key = i;
playlist[i].title = new char[1024];
playlist[i].path = new char[1024];
}
add_index = 0;
play_index = 0;
}
class_musics::~class_musics()
{
delete song;
delete feedback;
for (int i = 0; i < 255; i++) {
delete[]playlist[i].title;
delete[]playlist[i].path;
}
delete[]playlist;
delete parent;
}
void
class_musics::AddPlayList(char *title, char *path)
{
if (add_index < 255) {
strcpy(playlist[add_index].title, title);
strcpy(playlist[add_index].path, path);
add_index++;
} else { // Check for empty slot
for (int i = 0; i < 255; i++) {
if (playlist[i].title == "") {
strcpy(playlist[add_index].title, title);
strcpy(playlist[add_index].path, path);
break;
}
}
}
}
void
class_musics::DelPlayList(int index)
{
strcpy(playlist[index].title, "\0");
}
int
class_musics::SearchPlayList(char *title)
{
int match = 0;
for (int i = 0; i < 255; i++) {
match = strcmp(playlist[i].title, title);
if (match == 0)
return i;
}
return (-1);
}
void
class_musics::SetParent(Fl_Window * o)
{
feedback->parent = o;
}
Fl_Window *
class_musics::GetParent()
{
return feedback->parent;
}
class_musics musics;
class_music music;
// internal
static void
music_move(int value)
{
pthread_mutex_lock(&musics.movelock);
musics.move += value;
pthread_mutex_unlock(&musics.movelock);
}
void
music_done(void)
{
music_move(1);
}
inline void
music_term(void)
{
music.pause = false;
music.quit = true;
}
// external
bool
music_isstop(void)
{
return musics.stop;
}
bool
music_ispause(void)
{
return music.pause;
}
void
music_restart(void)
{
musics.restart = true;
}
void
music_stop(void)
{
musics.stop = true;
music_term();
}
void
music_play(void)
{
music.pause = false;
music.quit = false;
musics.stop = false;
}
void
music_pause(void)
{
music.pause = true;
}
void
music_unpause(void)
{
music.pause = false;
}
void
music_previous(void)
{
music_move(-1);
music_term();
}
void
music_next(void)
{
music_move(1);
music_term();
}
////////////////////////////////////////
// Client Play List
////////////////////////////////////////
void
SetPlayList(char *newSong)
{
strcpy(musics.song, newSong);
#ifdef CONFIG_DEBUG
printf("SetPlayList: %s\n", musics.song);
#endif
}
char *
GetPlayList()
{
int index = musics.SearchPlayList(musics.song);
return (musics.GetPlayListPath(index));
}
////////////////////////////////////////
// Client DSP plug-ins
////////////////////////////////////////
void
SetDsp(int newDsp)
{
musics.dsp = newDsp;
}
int
GetDsp()
{
return musics.dsp;
}
void *
GetArgs()
{
if (musics.dsp == FEEDBACK) {
return (void *) musics.feedback;
} else {
return 0;
}
}
void *dsp_rawdata;
--- NEW FILE: callbacks.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
////////////////////////////////////////////////////////////////////////////////
// Callbacks
////////////////////////////////////////////////////////////////////////////////
#include "callbacks.h"
#include <string.h>
#include <iostream.h>
--- NEW FILE: mp3buttons.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include <FL/Fl_Pixmap.H>
static char *image_pause[] = {
"32 32 -26 1",
" \377\377\377!\307\307\351\"uu\253#\212\212\324$\246\246\327%\323\323\353&//H\
\'\270\270\350(\247\247\350)ff\225*\233\233\344+LLl,\203\203\272-\203\203\312.\
\214\214\314/mm{0\227\227\317" "1\265\265\334" "2\332\332\357" "3)):4\201\201\
\276" "5\250\250\307" "6?\?W7\211\211\307" "8XX\177"
"9\223\223\334",
" ",
" 2%%%2 ",
" 22%%%%!!!! ",
" 22%%!!!!!!\'\'\'\' ",
" %%!!\'\'\'\'1\'\'\'\'\'\' ",
" %%!!11$$$*(((((\'(( ",
" %!!\'$$0999999*(((((( ",
" !!!1$09.#.##999**(((90 ",
" !!1$0.7######999**(*07 ",
" !\'1$0.#-#-####999****.,\" ",
" 111$0.-&&&&#&&&&9***9.\"\" ",
" !11$0.--&&&&#&&&&99***7\") ",
" 11$$07--&&&&#&&&&99**9,\")/ ",
" $$$0.---&&&&#&&&&9***9,)8+ ",
" 5$00.---&&&&#&&&&99**.\")+6 ",
" $0007---&&&&#&&&&99**.\"86+ ",
" ...7---&&&&#&&&&99*9,)+& ",
" 7777---&&&&#&&&&9*9.\"863 ",
" ,4444----####99999.4)63& ",
" \"\"444--#-####999.-)+3& ",
" \"))\"\"4--####99#74)+&3& ",
" ))))\"\"--7##.-4\")+&33 ",
" +888))\"\"\"\"\"\")+6333 ",
" ++++88888++63333 ",
" 66&6&66&&33333 ",
" 3333333333 ",
" 6336 ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_pause(image_pause);
static char *image_play[] = {
"32 32 -25 1",
" \377\377\377!\307\307\351\"uu\254#**;$\246\246\327%\323\323\353&\215\215\
\326\'\270\270\350(MMp)\247\247\350*ff\225+\204\204\313,\202\202\272-\233\233\
\344.88Q/\213\213\313" "0\227\227\317" "1\265\265\334" "2\332\332\357" "3\200\200\
\300" "4\250\250\307" "5WW\177" "6BB\\7\0\0\0"
"8\223\223\335",
" ",
" 2%%% ",
" 2%%%%!!!! ",
" 2%%!!!!!!\'\'\'\' ",
" 2%%!!\'\'\'\'1\'\'\'\'\'\' ",
" %%!!11$$$-)))))\')) ",
" %!!\'$$088&888-)))))) ",
" !!1$08&/&&&&88--)))80 ",
" !!1$0&//&/&&&888--)-0/ ",
" \'1$0&/++(+&&&&88----/,\" ",
" 111$0/++&77(+&&88----/\"\" ",
" 11$0/++++77775&888--8/\"* ",
" 11$$0+++++7777775&8--8,\"* ",
" $$$0/+++++77777777*8-8,*5( ",
" 4$00/++++37777777775-&\"*(6 ",
" $000/+++++77777776+--/\"56( ",
" 10///+++++777776+88-8,*(. ",
" ,//++++++777.3&8888/\"5.# ",
" ,,,33++++7.3&&&888&3*6## ",
" \"\"333+++3&+&&888&,*(## ",
" \"**\"\"3+++&&&&&&/3*(##. ",
" ****\"\"3+//&/+3\"*(### ",
" (555*\"\"\"\"\"\"\"*(6### ",
" 6((((5555((.#### ",
" 6.......###### ",
" ########## ",
" 6##6 ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_play(image_play);
static char *image_rew[] = {
"32 32 -24 1",
" \377\377\377!uu\255\"\223\223\333#\307\307\351$\215\215\326%\246\246\326&\
\323\323\353\'HHf(ff\226)\270\270\350*\251\251\351+\202\202\272,\203\203\312-8\
8R.\236\236\344/\227\227\317" "0\210\210\317" "1\265\265\334" "2\332\332\357" "3\
\200\200\277" "4WW~5\212\212\306" "6\0\0\0"
"7)):",
" ",
" ",
" 2&&&&#### ",
" &&######)))) ",
" &&##))))1)))))) ",
" &##11%%.%.****)** ",
" ##)1./\"\"$\"\"\"..****. ",
" ##1%/\"$0$$$\"\"\"..**../ ",
" ##1%/$00000$$\"\"\"..../5 ",
" )1%/$5,0000$$$\"\"....5+! ",
" 111%/0,,003\'$$$\"\"04.\"5!! ",
" 11%/5,,,(766$$$(-66.\"5!( ",
" 1%%%/0!\'666663\'76666.\"+!(\' ",
" %%%/(766666666666666.\"+(4\' ",
" %%/466666666666666666$!(\'\' ",
" %///5476666667666666.5!4\'\' ",
" 5/50,,!\'6666$!\'6666\"+(\'- ",
" 5555,,,,,476$$$\"(76$!4-7 ",
" +3333,,,000!$$\"\"\"\"3+(\'77 ",
" !!333,,000$$$$\"\"$+(\'77 ",
" !((!!3,00$$$$\"$03(477- ",
" ((((!!3,00$00+!(\'777 ",
" 4444((!!!!!((4-777 ",
" \'\'\'\'444444\'-7777 ",
" --------777777 ",
" 7777777777 ",
" \'77- ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_rew(image_rew);
static char *image_stop[] = {
"32 32 -26 1",
" \377\377\377!\307\307\351\"uu\253#\246\246\327$\323\323\353%\214\214\325&//I\
\'\270\270\350(\247\247\350)ff\225*\233\233\344+LLl,\203\203\272-\350\350\364.\
\203\203\312/\212\212\316" "0\227\227\317" "1\265\265\334" "2\332\332\357" "3)):4\
\201\201\276" "5\250\250\307" "6?\?W7\210\210\310" "8XX\177"
"9\223\223\334",
" ",
" -2$$$2 ",
" 22$$$$!!!! ",
" 22$$!!!!!!\'\'\'\' ",
" 2$$!!\'\'\'\'1\'\'\'\'\'\' ",
" $$!!11###*(((((\'(( ",
" !!\'##099%999*(((((( ",
" !!1#09%/%%%999**(((90 ",
" !!1#0%////%%%999**(*07 ",
" \'1#0%77//%/%%999****/,\" ",
" 111#0/..&&&&&&&&9***0/\"\" ",
" 11#0/...&&&&&&&&99***7\") ",
" 11##07...&&&&&&&&99**9,\") ",
" ###0/....&&&&&&&&9***9,)8+ ",
" 5#00/....&&&&&&&&99**%\")+6 ",
" #000/....&&&&&&&&99**/\"86+ ",
" 10//7....&&&&&&&&99*9,)+& ",
" 7777....&&&&&&&&9*9/\"863 ",
" ,4444...7///%%9999%4)63& ",
" \"\"\"44..///%%%9%9%,)+3& ",
" \")\"\"\"4../%%%%9%/4)+&3& ",
" )8))\"\"..//%/74\")+&33 ",
" 8888))\"\"\"\"\"\")+6333 ",
" ++++88888++63333 ",
" 66&6&66&&33333 ",
" 3333333333 ",
" 6336 ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_stop(image_stop);
static char *image_ffwd[] = {
"32 32 -25 1",
" \377\377\377!&&7\"tt\254#\307\307\351$\213\213\325%\246\246\327&\323\323\
\353\'LLn(gg\226)\270\270\350*\247\247\350+\200\200\270,\233\233\343-11F.\206\
\206\315/\214\214\312" "0\201\201\302" "1\227\227\317" "2\265\265\334" "3\332\332\
\357" "4XX\200" "5\250\250\307" "6AA[7\0\0\0"
"8\222\222\333",
" ",
" 3&&&3 ",
" 33&&&&#### ",
" 33&&######)))) ",
" 3&&##))))2)))))) ",
" &&##22%%%,*****)** ",
" &##)%%188888,,****** ",
" ##2%18$$$$$888,,***,1 ",
" ##2%18.$.$$$$888,,*,1/ ",
" )2%1/....$$$$888,,,,/+\" ",
" 222%1\'+....$\'0888,,,,/+\" ",
" 22%1/77-(..$77-(88,,,0\"( ",
" 22%%1.77777\'07777!4$,1+\"4 ",
" %%%1/.77777777777777-(+(4\' ",
" 5%11/07777777777777777\'(\'6 ",
" %111/.777777!777777!($\"46\' ",
" 2////077776\".777760,8+(\'- ",
" ///.07!4.$$$7!(88,8/\"46! ",
" ++000\"0...$$\"8$8888+(6!- ",
" \"\"++0....$$$8888$0(\'-! ",
" \"((\"\"00..$$$$8$/0(\'-!- ",
" ((((\"+0...$$.0\"(\'-!- ",
" \'444((\"\"\"\"\"((\'6!!! ",
" 6\'\'\'44444\'\'6!!!! ",
" 66---66--!!!!- ",
" !!!!!!!!!! ",
" 6--6 ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_ffwd(image_ffwd);
static char *image_add[] = {
"48 24 -32 1",
" \377\377\377!\251\251\327\"ee\226#ss\252$LLs%&&8&\271\271\347\'\312\312\367(\
\326\326\367)\233\233\317*\222\222\331+\207\207\325,XX\203-88U.\315\315\356/\
\234\234\343" "0\206\206\272" "1\202\202\313" "2\270\270\365" "3\273\273\337" "4\
\303\303\360" "5\252\252\355" "6\324\324\352" "7\305\305\345" "8\206\206\310"
"9\
\314\314\347:||\276;\220\220\314<DD`=\17\17\27>\31\31\'?\242\242\350",
" 666669999999999............(((((((((((\'4 ",
" 9666977777777777777747\'9.......(((((\'\'2? ",
" 799973333333&&&&&&&&3&&&&44444\'\'\'\'.\'\'2?0 ",
" 33333!!!!!!!!!!!!5!555&5&5&&&2&244442?0\" ",
" !3!!););;;*;**:\"******;:////0)555222)0\"$ ",
" !!!);888811111%>#1++++\"%+***%#/?\?55?0#,< ",
" !!!);88881111:=,-+1+1\"\"%**#1%#/?\?55?0#,< ",
" !!));88881111$<+>:+#=$=%+---=#/?\?55?0#,< ",
" !!!);88181111><\"%$1-,+,%:=**=#/?\?55?0#,< ",
" !!!);8888111#=%%%>+%\"+\"%\"%**%#/?\?55?0#,< ",
" !!!);8888111$-11+>#-$+$%1=++=#/?\?55?0#,< ",
" !));0#:#####=\"#:#<%#%%%%:$>%=\"+;**);#\"<< ",
" );0#\",,,,,,,,,,,,,,,,,,,,\",\"\"\"\"\"\"\"#\",<-% ",
" 0#\"$<------------------<--<-<<<<<$<<-%%- ",
" #,<-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-% ",
" ,<%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-%-%%- ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_add(image_add);
static char *image_cancel[] = {
"48 24 -32 1",
" \377\377\377!dd\225\"\251\251\326#\243\243\346$\221\221\325%\272\272\346&\
\211\211\330\'&&8(\314\314\367)YY\205*\326\326\367+\203\203\314,88U-\315\315\
\356.\207\207\273/\234\234\317" "0\274\274\337" "1HHj2\231\231\341" "3WW|4\304\
\304\357" "5\276\276\366" "6\324\324\352" "7\305\305\346"
"8MMt9\6\6\t:\314\314\
\347;BB_<\27\27#=zz\275>\257\257\347?rr\246",
" 66666::::::::::------------**********((5 ",
" :666:777777777777777444--------*****((5# ",
" 7:::7000000%%%%%%%%%%%%%%5444(4(((((45#. ",
" 0000>\"\"\"\"\"\"\"\"\"\"\"\">\">>>>>>>>>%%5554455#.! ",
" \"0\"\"//.?\?$$$$$$$$$$$$22222#####>>/2>2.!8 ",
" \"\"\"/$89\'<,++++++++&&&&&&&$$2222##))#.?3; ",
" \"\"\"/=9?++\'8++!!++?=!=&&&?=$$2=+##))#.?3; ",
" \"\"//8,+++++=<;,<+\'<89!&,,\'12,;,;#))#.?3; ",
" \"\"\"/81.++++=?!89+\')+88=<&&8+<?\?<+))#.?3; ",
" \"\"\"/3\'+++!8=<,19+\'!&11!\'&$$?<833$3)#.?3; ",
" \"\"\"/.91+?<8!\'+!9+\'!&88=9+=<&9$232))#.?3; ",
" \"//$.!\'99;=?\'<,9?\')=;;=8<<!+8<<;$88$?!1; ",
" /$.?!333)33))))))))))))))))!!!!!!!?!3;,\' ",
" .?!3;,,,,,,,,,,,,,,,,;,;;;;;;;;1111;,\'\', ",
" ?);,\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\',\'\
",
" );\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\',\',\'\
\' ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_cancel(image_cancel);
static char *image_del[] = {
"48 24 -32 1",
" \377\377\377!dd\225\"\251\251\327#rr\247$MMu%\271\271\347&&&8\'\313\313\367(\
XX\204)\326\326\367*\211\211\330+\233\233\320,\222\222\325-\202\202\315.\231\
\231\344/\202\202\266" "0\315\315\357" "1\270\270\365" "2\273\273\337" "399V4\302\
\302\362" "5\252\252\355" "6\325\325\351" "7\306\306\347" "8\314\314\347"
"9\220\
\220\313:\r\r\24;DD`<\206\206\310=xx\272>\211\211\300?\242\242\350",
" 666668888888888880000000000)))))))))))\'4 ",
" 8666877777777777777777700000000)))))\'\'1? ",
" 788772222222%%%%%%%%%%4%%44447\'\'\'0\'\'41\"/ ",
" 22222\"\"\"\"\"\"\"\"\"\"\"\"5\"5\"5\"%5%5%%11%44441?/! ",
" \"2\"\"++,,9,,,,<#!#/,,.,..../+?\?555111+/!$ ",
" \"\"\"+9<<<<<---!:&&:3******,&#...?\?55?>#(; ",
" \"\"\"+9<<<<----!&---&$**##**&!...?\?55?>#(; ",
" \"\"\"+9<<<<----!&---(&*3333,&#...?\?55?>#(; ",
" \"\"\"+9<<-<----(&--*!&=:!!:=&#...?\?55?>#(; ",
" \"\"++9<<<<----!&---$3!:$$$=&#,..?\?55?>#(; ",
" \"\"\"+9<<<<<---!&--=:!-:-*$*&#..?\?\?55?>#(; ",
" \"++9/==#=#=#=(::::$==$:&3=&!-<*9,,,9#!;3 ",
" +9/#!((((((((($$((((((((!(!(!!!!#!#!(;3& ",
" >#!$;33333333333333333333;3;;;;;;;;;3&&3 ",
" #(;3&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&3& ",
" !;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&3&3&&3 ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_del(image_del);
static char *image_delall[] = {
"48 24 -32 1",
" \377\377\377!\250\250\325\"\204\204\313#&&8$\313\313\367%\273\273\343&vv\
\261\'\245\245\341(\326\326\367)\233\233\317*\212\212\331+XX\203,cc\230-88U.\
\221\221\317/\207\207\274" "0\315\315\357" "1\270\270\365" "2\260\260\341" "3\302\
\302\362" "4\250\250\360" "5\325\325\351" "6\305\305\347" "7bb\214" "8}}\301"
"9\
\314\314\347:\13\13\22;DDa<\34\34+=\231\231\336>nn\237?NNv",
" 555559999999999990000000000((((((((((($3 ",
" 9555966666666666666666600000000((((($$1\' ",
" 69996%%%%%%%%%%%%%%%%%3%%3333$$$$0$$31\'/ ",
" %%%%2!!!!!!!\'!\'\'\'\'2\'22222222)21333331\'/7 ",
" !22!)))/>>>8.......=&.====.\'#+4.4111=/7? ",
" !!!).\"\",:##:-\"\"\"\"*\"*#,***8:8-+7<444\'/>+; ",
" !!!)./\"7#\"\"\"#?\"\">>*\"#,****8-?+-=444\'/>+; ",
" !!!).\"\",#\"\"\"+#\"----\"#,**8#-?<#+#-44\'/>+; ",
" !!!).\"\"7#\"\"\",#&:,,:>#,**\"?+?-?,++44\'/>+; ",
" !!!)./\",#\"\"\"?-,:?;?&#,****+#?\?</444\'/>+; ",
" !!!).\"\"7#\"\"&:,8:8\"?8#,***8<*-+8<444\'/>+; ",
" !))./&&+::::;&&;<<-&#+88888\"#?....=.&7?- ",
" )./>7++++?+++++++++++++++777,7,,>>>7+;-# ",
" /&7?;------------------;-;-;;;;;;;;;-##- ",
" &7;-##################################-# ",
" 7;#####<#<#<#<####################-#-##- ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_delall(image_delall);
static char *image_ok[] = {
"48 24 -32 1",
" \377\377\377!\242\242\350\"\251\251\327#ff\226$\271\271\347%\312\312\367&\'\
\'8\'ss\251(\326\326\367)\231\231\344*\226\226\315+\221\221\331,\205\205\323-\
\315\315\356.99U/\206\206\273" "0XX\206" "1\270\270\365" "2\273\273\337" "3FFi4\
\303\303\360" "5\252\252\355" "6\324\324\352" "7\305\305\345"
"8YYz9KKu:\314\314\
\347;\13\13\21<CC_=zz\300>\33\33*?\204\204\312",
" 66666::::::::::------------(((((((((((%4 ",
" :666:77777777777777747%:-------(((((%%1! ",
" 7:::72222222$$$$$$$$2$$$$44444%%%%-%%1!/ ",
" 22222\"\"\"\"\"\"\"\"\"\"\"\"5\"555$5$5$$$1$144441!/# ",
" \"2\"\"****+*++++++#\'+++//))+\'!!!555111)/#9 ",
" \"\"\"**?\?\?\?\?\?\?\?\?9;&>;\',99,?>0+)))!!55!/\'8< ",
" \"\"\"**?\?\?\?\?\?\?\?\';\',,0>,99?>0++)))!!55!/\'8< ",
" \"\"\"**?\?\?\?\?\?\?\?9.?,,,;\'9<>9++))))!!55!/\'8< ",
" \"\"\"**?\?\?\?\?\?\?\?33,?,,&>,++)))!!55!/\'8< ",
" \"\"\"**?\?\?\?\?\?\?\?9&,,,,;=9&,<.+))))!!55!/\'8< ",
" \"\"\"**/?\?\?\?\?\?,=;3,=.&,99++>0+))!!!55!/\'8< ",
" \"\"**/\'=\'\'\'\'\'\'=#&;;&\'=<3==\';\'?\?,+++**\'#3< ",
" *//\'#080000000000000000000#0######\'#8<.& ",
" /\'#8<..................<.<.<<<<<333<.&&. ",
" \'8<.&&&&&&&&&&&>&&&&&&&&&&&&&&&&&&&&&.&& ",
" 8<&&>&>&>&>&>&>&&&&&&&&&&&&&&&&&&&&&&&&. ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_ok(image_ok);
static char *image_list[] = {
"48 24 -32 1",
" \377\377\377!\251\251\327\"NNu#cc\225$\271\271\347%&&8&\313\313\367\'XX\203(\
\326\326\367)\231\231\344*\234\234\317+ss\247,\207\207\326-\224\224\332.\202\
\202\315/\315\315\357" "0\202\202\264" "199V2\270\270\365" "3\273\273\337" "4\302\
\302\362" "5\252\252\355" "6\325\325\351" "7\306\306\347" "8\206\206\310"
"9\314\
\314\347:\220\220\315;\3\3\5<DD`=zz\277>\211\211\300?\242\242\347",
" 66666999999999999//////////(((((((((((&4 ",
" 96669777777777777777777////////(((((&&2? ",
" 799773333333$$$$$$$$$$4$$44447&&&/&&42!0 ",
" 33333!!!!!!!!!!!!5!5!5!$5$5$$22$44442?0# ",
" !3!!*:-:::-:8+:--:+---)-))?\?\?\?555222*0#\" ",
" !!!*:>888...#%...,%,,,,,,#\"-)))?\?55?>+\'< ",
" !!!*:8888...#%....#,,#+,.11.)))?\?55?>+\'< ",
" !!**:8888...#%....;.%<1%=%%+-))?\?55?>+\'< ",
" !!!*:88.8...#%....;,;\".#,\"\"-)))?\?55?>+\'< ",
" !!!*:8888...#%...,;,+1;1.\"\"-)))?555?>+\'< ",
" !!!*:88888..#%....;,%.,%#\"\"-))?\?\?55?>+\'< ",
" !**:0=+++=++\';;;;\';=\"%%1=\';\"88,:---:+#<1 ",
" *:0+#\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'#########+#\'<1% ",
" >+#\"<1111111111111111111111<<<<<<\"<<1%%1 ",
" +\'<1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1% ",
" \'<%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1%1%%1 ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
static Fl_Pixmap pixmap_list(image_list);
--- NEW FILE: fft.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include "fft.h"
//#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#ifndef PI
#ifdef M_PI
#define PI M_PI
#else
#define PI 3.14159265358979323846 /* pi */
#endif
#endif
GR_EVENT ev;
static int flag = -1;
/* ########### */
/* # Structs # */
/* ########### */
struct _struct_fft_state
{
/* Temporary data stores to perform FFT in. */
short int real[FFT_BUFFER_SIZE];
short int imag[FFT_BUFFER_SIZE];
};
/* ############################# */
/* # Local function prototypes # */
/* ############################# */
static void fft_prepare(const sound_sample * input, short int *re,
short int *im);
static void fft_calculate(short int *re, short int *im);
static void fft_output(const short int *re, const short int *im, int *output);
static int reverseBits(unsigned int initial);
/* #################### */
/* # Global variables # */
/* #################### */
/* Table to speed up bit reverse copy */
static unsigned int bitReverse[FFT_BUFFER_SIZE];
/* The next two tables could be made to use less space in memory, since they
* overlap hugely, but hey. */
static short int sintable[FFT_BUFFER_SIZE / 2];
static short int costable[FFT_BUFFER_SIZE / 2];
/* ############################## */
/* # Externally called routines # */
/* ############################## */
/* --------- */
/* FFT stuff */
/* --------- */
/*
* Initialisation routine - sets up tables and space to work in.
* Returns a pointer to internal state, to be used when performing calls.
* On error, returns NULL.
* The pointer should be freed when it is finished with, by fft_close().
*/
fft_state *
fft_init(void)
{
fft_state *state;
unsigned int i;
state = (fft_state *) malloc(sizeof(fft_state));
if (!state)
return NULL;
for (i = 0; i < FFT_BUFFER_SIZE; i++) {
bitReverse[i] = reverseBits(i);
}
for (i = 0; i < FFT_BUFFER_SIZE / 2; i++) {
float j = 2 * PI * i / FFT_BUFFER_SIZE;
float test;
costable[i] = (short int) (cos(j) * (1 << 15));
test = cos(j);
sintable[i] = (short int) (sin(j) * (1 << 15));
}
return state;
}
/*
* Do all the steps of the FFT, taking as input sound data (as described in
* sound.h) and returning the intensities of each frequency as floats in the
* range 0 to ((FFT_BUFFER_SIZE / 2) * 32768) ^ 2
*
* FIXME - the above range assumes no frequencies present have an amplitude
* larger than that of the sample variation. But this is false: we could have
* a wave such that its maximums are always between samples, and it's just
* inside the representable range at the places samples get taken.
* Question: what _is_ the maximum value possible. Twice that value? Root
* two times that value? Hmmm. Think it depends on the frequency, too.
*
* The input array is assumed to have FFT_BUFFER_SIZE elements,
* and the output array is assumed to have (FFT_BUFFER_SIZE / 2 + 1) elements.
* state is a (non-NULL) pointer returned by fft_init.
*/
void
fft_perform(const sound_sample * input, int *output, fft_state * state,
int dataFrameSkip)
{
// initalize flag
if (flag == -1)
flag = dataFrameSkip;
if (flag == dataFrameSkip) {
flag = 0;
/* Convert data from sound format to be ready for FFT */
fft_prepare(input, state->real, state->imag);
/* Do the actual FFT */
fft_calculate(state->real, state->imag);
/* Convert the FFT output into intensities */
fft_output(state->real, state->imag, output);
} else {
flag++;
return;
}
}
/*
* Free the state.
*/
void
fft_close(fft_state * state)
{
if (state)
free(state);
}
/* ########################### */
/* # Locally called routines # */
/* ########################### */
/*
* Prepare data to perform an FFT on
*/
static void
fft_prepare(const sound_sample * input, short int *re, short int *im)
{
unsigned int i;
short int *realptr = re;
short int *imagptr = im;
/* Get input, in reverse bit order */
for (i = 0; i < FFT_BUFFER_SIZE; i++) {
*realptr++ = input[bitReverse[i]];
*imagptr++ = 0;
}
}
/*
* Take result of an FFT and calculate the intensities of each frequency
* Note: only produces half as many data points as the input had.
* This is roughly a consequence of the Nyquist sampling theorm thingy.
* (FIXME - make this comment better, and helpful.)
*
* The two divisions by 4 are also a consequence of this: the contributions
* returned for each frequency are split into two parts, one at i in the
* table, and the other at FFT_BUFFER_SIZE - i, except for i = 0 and
* FFT_BUFFER_SIZE which would otherwise get float (and then 4* when squared)
* the contributions.
*/
static void
fft_output(const short int *re, const short int *im, int *output)
{
int *outputptr = output;
const short int *realptr = re;
const short int *imagptr = im;
//int *endptr = output + FFT_BUFFER_SIZE / 2;
int *endptr = output + 256;
#ifdef DEBUG
unsigned int i, j;
#endif
while (outputptr <= endptr) {
*outputptr = (*realptr * *realptr) + (*imagptr * *imagptr);
outputptr++;
realptr++;
imagptr++;
}
/* Do divisions to keep the constant and highest frequency terms in scale
* with the other terms. */
*output /= 4;
*endptr /= 4;
#ifdef DEBUG
printf("Recalculated input:\n");
for (i = 0; i < FFT_BUFFER_SIZE; i++) {
float val_real = 0;
float val_imag = 0;
for (j = 0; j < FFT_BUFFER_SIZE; j++) {
float fact_real = cos(-2 * j * i * PI / FFT_BUFFER_SIZE);
float fact_imag = sin(-2 * j * i * PI / FFT_BUFFER_SIZE);
val_real += fact_real * re[j] - fact_imag * im[j];
val_imag += fact_real * im[j] + fact_imag * re[j];
}
printf("%5d = %8f + i * %8f\n", i,
val_real / FFT_BUFFER_SIZE, val_imag / FFT_BUFFER_SIZE);
}
printf("\n");
#endif
}
/*
* Actually perform the FFT
*/
static void
fft_calculate(short int *re, short int *im)
{
unsigned int i, j, k;
unsigned int exchanges;
int fact_real, fact_imag;
int tmp_real, tmp_imag;
int tmp1, tmp2;
unsigned int factfact;
/* Set up some variables to reduce calculation in the loops */
exchanges = 1;
//factfact = FFT_BUFFER_SIZE / 2;
factfact = 256;
/* Loop through the divide and conquer steps */
for (i = FFT_BUFFER_SIZE_LOG; i != 0; i--) {
/* In this step, we have 2 ^ (i - 1) exchange groups, each with
* 2 ^ (FFT_BUFFER_SIZE_LOG - i) exchanges
*/
GrPeekEvent(&ev);
if (ev.type == GR_EVENT_TYPE_BUTTON_DOWN ||
ev.type == GR_EVENT_TYPE_BUTTON_DOWN ||
ev.type == GR_EVENT_TYPE_UPDATE) {
fl_handle(ev);
}
/* Loop through the exchanges in a group */
for (j = 0; j != exchanges; j++) {
/* Work out factor for this exchange
* factor ^ (exchanges) = -1
* So, real = cos(j * PI / exchanges),
* imag = sin(j * PI / exchanges)
*/
fact_real = costable[j * factfact];
fact_imag = sintable[j * factfact];
/* Loop through all the exchange groups */
for (k = j; k < FFT_BUFFER_SIZE; k += exchanges << 1) {
int k1 = k + exchanges;
/* newval[k] := val[k] + factor * val[k1]
* newval[k1] := val[k] - factor * val[k1]
**/
/* FIXME - potential scope for more optimization here? */
tmp1 = fact_real;
tmp1 *= re[k1];
tmp2 = fact_imag;
tmp2 *= im[k1];
tmp_real = tmp1 - tmp2;
tmp1 = fact_real;
tmp1 *= im[k1];
tmp2 = fact_imag;
tmp2 *= re[k1];
tmp_imag = tmp1 + tmp2;
tmp_real >>= 15;
tmp_imag >>= 15;
re[k1] = re[k] - tmp_real;
im[k1] = im[k] - tmp_imag;
re[k] += tmp_real;
im[k] += tmp_imag;
}
}
exchanges <<= 1;
factfact >>= 1;
}
}
static int
reverseBits(unsigned int initial)
{
unsigned int reversed = 0, loop;
for (loop = 0; loop < FFT_BUFFER_SIZE_LOG; loop++) {
reversed <<= 1;
reversed += (initial & 1);
initial >>= 1;
}
return reversed;
}
--- NEW FILE: fspl_panel.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
[...1186 lines suppressed...]
if (title[i] == '@') {
if (title[i + 1] == '.') {
int k = 0;
for (int j = i + 2; j < MAX_NAME_LENGTH + 2; j++, k++) {
buffer[k] = title[j];
}
strcpy(title, buffer);
break;
}
}
}
delete[]buffer;
buffer = 0;
}
--- NEW FILE: dsp_feedback.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include "dsp_feedback.h"
#include <iostream.h>
#include <pthread.h>
#include <string.h>
#include "/usr/include/math.h"
fft_state *
Dsp_Feedback::state;
Dsp_Feedback::Dsp_Feedback()
{
//cout << "Dsp_Feedback(): " << (void*)this << endl;
feedback = new feedback_struct;
//cout << "new feedback" << (void*)feedback << endl;
init = 0;
if (!init) {
Init();
}
state = NULL;
state = fft_init();
scale = 100 / log(256);
dataFrameSkip = 5;
}
Dsp_Feedback::~Dsp_Feedback()
{
//printf("~Dsp_Feedback()\n");
//printf("\t- delete feedback\n");
delete feedback;
}
void
Dsp_Feedback::Init()
{
////////////////////////////////////////
// Spectragraph
////////////////////////////////////////
int EQ_X = 30;
int EQ_Y = 205;
eq0 = new Fl_Eq(EQ_X, EQ_Y, 11, 62);
eq0->type(2);
eq0->range(0, 100);
//cout << "allocated eq0 addr: " << (void*)eq0 << endl;
eq1 = new Fl_Eq(EQ_X + 12, EQ_Y, 11, 62);
eq1->type(2);
eq1->range(0, 100);
//cout << "allocated eq1 addr: " << (void*)eq1 << endl;
eq2 = new Fl_Eq(EQ_X + 24, EQ_Y, 11, 62);
eq2->type(2);
eq2->range(0, 100);
//cout << "allocated eq2 addr: " << (void*)eq2 << endl;
eq3 = new Fl_Eq(EQ_X + 36, EQ_Y, 11, 62);
eq3->type(2);
eq3->range(0, 100);
//cout << "allocated eq3 addr: " << (void*)eq3 << endl;
eq4 = new Fl_Eq(EQ_X + 48, EQ_Y, 11, 62);
eq4->type(2);
eq4->range(0, 100);
//cout << "allocated eq4 addr: " << (void*)eq4 << endl;
eq5 = new Fl_Eq(EQ_X + 60, EQ_Y, 11, 62);
eq5->type(2);
eq5->range(0, 100);
//cout << "allocated eq5 addr: " << (void*)eq5 << endl;
eq6 = new Fl_Eq(EQ_X + 72, EQ_Y, 11, 62);
eq6->type(2);
eq6->range(0, 100);
//cout << "allocated eq6 addr: " << (void*)eq6 << endl;
eq7 = new Fl_Eq(EQ_X + 84, EQ_Y, 11, 62);
eq7->type(2);
eq7->range(0, 100);
//cout << "allocated eq7 addr: " << (void*)eq7 << endl;
eq8 = new Fl_Eq(EQ_X + 96, EQ_Y, 11, 62);
eq8->type(2);
eq8->range(0, 100);
//cout << "allocated eq8 addr: " << (void*)eq8 << endl;
eq9 = new Fl_Eq(EQ_X + 108, EQ_Y, 11, 62);
eq9->type(2);
eq9->range(0, 100);
//cout << "allocated eq9 addr: " << (void*)eq9 << endl;
eq10 = new Fl_Eq(EQ_X + 120, EQ_Y, 11, 62);
eq10->type(2);
eq10->range(0, 100);
//cout << "allocated eq10 addr: " << (void*)eq10 << endl;
eq11 = new Fl_Eq(EQ_X + 132, EQ_Y, 11, 62);
eq11->type(2);
eq11->range(0, 100);
//cout << "allocated eq11 addr: " << (void*)eq11 << endl;
eq12 = new Fl_Eq(EQ_X + 144, EQ_Y, 11, 62);
eq12->type(2);
eq12->range(0, 100);
//cout << "allocated eq12 addr: " << (void*)eq12 << endl;
eq13 = new Fl_Eq(EQ_X + 156, EQ_Y, 11, 62);
eq13->type(2);
eq13->range(0, 100);
//cout << "allocated eq13 addr: " << (void*)eq13 << endl;
eq14 = new Fl_Eq(EQ_X + 168, EQ_Y, 11, 62);
eq14->type(2);
eq14->range(0, 100);
//cout << "allocated eq14 addr: " << (void*)eq14 << endl;
init = 1;
}
void *
Dsp_Feedback::ApplyDsp(void *data, int skip)
{
dataFrameSkip = skip;
if (data != 0)
FeedbackFilter(data);
return (void *) buffer;
}
void
Dsp_Feedback::SetArgs(void *args)
{
feedback_struct *tmp = (feedback_struct *) args;
feedback->Hz = tmp->Hz;
feedback->SR = tmp->SR;
feedback->parent = tmp->parent;
tmp = 0;
}
void
Dsp_Feedback::FeedbackFilter(void *data)
{
buffer = (short int *) data;
/*
double F, Pi;
int L, Hz, SR;
Hz = feedback->Hz;
SR = feedback->SR;
L = RAWDATASIZE;
Pi = 3.1415;
F = (2 * Pi * Hz) / SR;
for ( int T = 0; T < RAWDATASIZE
buffer[T] = int(buffer[T]*sin(F*T));
*/
// static fft_state *state = NULL;
//float tmp_out[257];
//int dest[257];
int i;
//short int sample[512];
//double scale = 100/log(256);
for (i = 0; i < RAWDATASIZE; i += 512) {
memcpy((short int *) &sample[0], (short int *) &buffer[i], 512);
//if(!state)
//state = fft_init();
fft_perform(sample, tmp_out, state, dataFrameSkip);
for (int j = 0; j < 256; j++) {
dest[j] = ((int) sqrt(tmp_out[j + 1]) >> 8);
}
int k, c;
int y;
int xscale[] =
{ 0, 1, 2, 3, 5, 7, 10, 14, 20, 28, 50, 101, 202, 237, 248, 255 };
//int xscale[] = {0, 1, 2, 3, 5, 7};
for (k = 0; k < 15; k++) {
for (c = xscale[k], y = 0; c < xscale[k + 1]; c++) {
if (dest[c] > y)
y = dest[c];
}
if (y != 0) {
y = (int) (log(y) * scale);
if (y > 100)
y = 100;
} // if
if (y >= 0) {
switch (c) {
case 1:
eq0->value(y);
eq0->redraw();
break;
case 2:
eq1->value(y);
eq1->redraw();
break;
case 3:
eq2->value(y);
eq2->redraw();
break;
case 5:
eq3->value(y);
eq3->redraw();
break;
case 7:
eq4->value(y);
eq4->redraw();
break;
case 10:
eq5->value(y);
eq5->redraw();
break;
case 14:
eq6->value(y);
eq6->redraw();
break;
case 20:
eq7->value(y);
eq7->redraw();
break;
case 28:
eq8->value(y);
eq8->redraw();
break;
case 50:
eq9->value(y);
eq9->redraw();
break;
case 101:
eq10->value(y);
eq10->redraw();
break;
case 202:
eq11->value(y);
eq11->redraw();
break;
case 237:
eq12->value(y);
eq12->redraw();
break;
case 248:
eq13->value(y);
eq13->redraw();
break;
case 255:
eq14->value(y);
eq14->redraw();
break;
}
}
} // for 16
//cout << endl;
} // for 512
}
--- NEW FILE: Mp3_Browser.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef Mp3_Browser_H
#define Mp3_Broswer_H
#include "Mp3_Node.h"
#include <FL/Fl.H>
#include <Flek/Fl_Toggle_Tree.H>
#include <FL/Fl_Pixmap.H>
#include <stdio.h>
class Mp3_Browser:public Fl_Toggle_Tree
{
public:
Mp3_Browser(int x, int y, int w, int h);
virtual ~ Mp3_Browser();
Mp3_Node *add_next(char *label = 0, char *time_label = 0, int can_open =
1, Fl_Pixmap * pixmap = 0, void *d = 0)
{
Mp3_Node *node;
node = new Mp3_Node(label, time_label, can_open, pixmap, d);
Fl_Toggle_Tree::add_next(node);
return node;
}
protected:
void draw_node(int depth, int cy, Fl_Toggle_Node * node);
void draw_label(Mp3_Node * node, int indent, int x, int y, int w, int h);
};
#endif
--- NEW FILE: mp3utils.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
////////////////////////////////////////////////////////////////////////////////
// MP3 Utility Methods
////////////////////////////////////////////////////////////////////////////////
#include "mp3utils.h"
#define HAVE_PTHREAD_H
#include "mpegsound.h"
void
Mp3Utils::strman(char *str, int max)
{
int i;
str[max] = 0;
for (i = max - 1; i >= 0; i--)
if (((unsigned char) str[i]) < 26 || str[i] == ' ')
str[i] = 0;
else
break;
}
//--------------------------------------------------------------------------------
void
Mp3Utils::stripfilename(char *dtr, char *str, int max)
{
char *ss;
int p = 0, s = 0;
for (; str[p]; p++)
if (str[p] == '/') {
p++;
s = p;
}
ss = str + s;
for (p = 0; p < max && ss[p]; p++)
dtr[p] = ss[p];
dtr[p] = 0;
}
//--------------------------------------------------------------------------------
// Parse out MP3 title, etc.
void
Mp3Utils::parseID3(char *path, char *title)
{
Soundinputstream *fp;
int err;
fp = Soundinputstream::hopen(path, &err);
int tryflag = 0;
fp->setposition(fp->getsize() - 128);
for (;;) {
if (fp->getbytedirect() == 0x54) {
if (fp->getbytedirect() == 0x41) {
if (fp->getbytedirect() == 0x47) {
fp->_readbuffer(title, 30);
strman(title, 30);
//fp->_readbuffer(data->artist ,30);strman(data->artist, 30);
//fp->_readbuffer(data->album ,30);strman(data->album, 30);
//fp->_readbuffer(data->year , 7);strman(data->year, 7);
//fp->_readbuffer(data->comment ,30);strman(data->comment, 30);
break;
}
}
}
tryflag++;
if (tryflag == 1) {
fp->setposition(fp->getsize() - 125); // for mpd 0.1, Sorry..
} else {
stripfilename(title, path, 1024);
break;
}
}
fp->setposition(0);
}
--- NEW FILE: Mp3_Node.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include "Mp3_Node.h"
--- NEW FILE: Fl_Eq.cxx ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
//
// Equalizer Slider widget for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-1999 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs at easysw.com".
//
#include <FL/Fl.H>
#include <FL/Fl_Eq.H>
#include <FL/fl_draw.H>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
//#include <iostream.h>
void
Fl_Eq::_Fl_Eq()
{
slider_size_ = 0;
slider_ = 0; // FL_UP_BOX;
}
Fl_Eq::Fl_Eq(int x, int y, int w, int h, const char *l)
:
Fl_Valuator(x, y, w, h, l)
{
percent1 = 33;
percent2 = 33;
percent3 = 34;
color1 = FL_GREEN;
color2 = FL_YELLOW;
color3 = FL_RED;
box(FL_DOWN_BOX);
_Fl_Eq();
}
Fl_Eq::Fl_Eq(uchar t, int x, int y, int w, int h, const char *l)
:
Fl_Valuator(x, y, w, h, l)
{
percent1 = 33;
percent2 = 33;
percent3 = 34;
color1 = FL_GREEN;
color2 = FL_YELLOW;
color3 = FL_RED;
type(t);
box(t == FL_HOR_NICE_SLIDER || t == FL_VERT_NICE_SLIDER ?
FL_FLAT_BOX : FL_DOWN_BOX);
_Fl_Eq();
}
void
Fl_Eq::slider_size(double v)
{
if (v < 0)
v = 0;
if (v > 1)
v = 1;
if (slider_size_ != float (v)) {
slider_size_ = float (v);
damage(FL_DAMAGE_EXPOSE);
}
}
void
Fl_Eq::bounds(double a, double b)
{
if (minimum() != a || maximum() != b) {
Fl_Valuator::bounds(a, b);
damage(FL_DAMAGE_EXPOSE);
}
}
void
Fl_Eq::Range(int p1, int p2)
{
percent1 = p1;
percent2 = p2;
percent3 = 100 - (p1 + p2);
}
void
Fl_Eq::Colors(Fl_Color c1, Fl_Color c2, Fl_Color c3)
{
color1 = c1;
color2 = c2;
color3 = c3;
}
void
Fl_Eq::slider_ver_lines(int x, int y, int w, int h, int W, Fl_Color c)
{
int cx = x + w / 2;
int cy = y + h / 2;
fl_color(FL_BLACK);
int stepVal = 4;
double stepBoxSize = 3;
if (type() != FL_HORIZONTAL) {
double curStep = 0.0;
double p1 = percent1 / 100.0;
double p2 = percent2 / 100.0;
int convW = W / stepVal;
for (int i = 1; i < (w - 1); i = i + stepVal, curStep++) {
c = color1;
if (curStep > (convW * p1)) {
c = color2;
}
if (curStep > (convW * (p1 + p2))) {
c = FL_RED;
}
draw_box(FL_FLAT_BOX, (x + i), (y + 1), (int) stepBoxSize,
(h - 2), c);
}
} else {
if (w > 0 && h > 0) {
if (w < 17) {
w = 17;
slider_size(double (w) / double (W));
slider_size_min_ = slider_size();
}
draw_box(FL_BORDER_BOX, x, y, w, h, c);
fl_color(FL_BLACK);
cx = x + w / 2;
fl_line(cx, cy - h / 2 + 4, cx, cy + h / 2 - 4);
fl_line(cx - 3, cy - h / 2 + 4, cx - 3, cy + h / 2 - 4);
fl_line(cx + 3, cy - h / 2 + 4, cx + 3, cy + h / 2 - 4);
}
}
}
void
Fl_Eq::slider_hor_lines(int x, int y, int w, int h, int W, Fl_Color c)
{
int cx = x + w / 2;
int cy = y + h / 2;
fl_color(FL_BLACK);
int stepVal = 4;
double stepBoxSize = 3;
if (type() != FL_VERTICAL) {
// 1. Green
c = fl_color_cube(105 * FL_NUM_RED / 256,
255 * FL_NUM_GREEN / 256, 0 * FL_NUM_BLUE / 256);
int curStep = 0;
double val = value();
int event_y = 0;
if (event_y == 0)
event_y = abs((int) (val - Fl_Widget::h())) + y;
else
event_y = Fl::event_y();
for (int i = Fl_Widget::h() + y - stepVal; i > event_y;
i = i - stepVal, curStep++) {
// 2. Green-Yellow
if (curStep == (w / 4))
c = fl_color_cube(140 * FL_NUM_RED / 256,
255 * FL_NUM_GREEN / 256,
0 * FL_NUM_BLUE / 256);
else if (curStep == (w / 4 + 1))
c = fl_color_cube(173 * FL_NUM_RED / 256,
255 * FL_NUM_GREEN / 256,
47 * FL_NUM_BLUE / 256);
// 4. Yellow
else if ((curStep > (w / 4 + 1)) && (curStep < (w - (w / 2))))
c = FL_YELLOW;
// 5. Orange
else if (curStep == (w - (w / 2)))
c = fl_color_cube(255 * FL_NUM_RED / 256,
195 * FL_NUM_GREEN / 256, 0);
else if (curStep == (w - (w / 4) + 1))
c = fl_color_cube(255 * FL_NUM_RED / 256,
105 * FL_NUM_GREEN / 256, 0);
// 6. Red
else if (curStep > (w - (w / 4) + 1))
c = FL_RED;
if (event_y == 0)
break;
draw_box(FL_FLAT_BOX, (x + 1), i, (w - 2), (int) stepBoxSize, c);
}
} else {
if (w > 0 && h > 0) {
if (h < 17) {
h = 17;
slider_size(double (h) / double (W));
slider_size_min_ = slider_size();
}
draw_box(FL_BORDER_BOX, x, y, w, h, c);
fl_color(FL_BLACK);
cy = y + h / 2;
fl_line(cx + w / 2 - 4, cy, cx - w / 2 + 4, cy);
fl_line(cx + w / 2 - 4, cy - 3, cx - w / 2 + 4, cy - 3);
fl_line(cx + w / 2 - 4, cy + 3, cx - w / 2 + 4, cy + 3);
}
}
}
int
Fl_Eq::scrollvalue(int p, int w, int t, int l)
{
// p = position, first line displayed
// w = window, number of lines displayed
// t = top, number of first line
// l = length, total number of lines
step(1, 1);
if (p + w > t + l)
l = p + w - t;
slider_size(w >= l ? 1.0 : double (w) / double (l));
#ifdef PDA
if (slider_size() < slider_size_min_) {
slider_size(slider_size_min_);
}
#endif
bounds(t, l - w + t);
return value(p);
}
// All slider interaction is done as though the slider ranges from
// zero to one, and the left (bottom) edge of the slider is at the
// given position. Since when the slider is all the way to the
// right (top) the left (bottom) edge is not all the way over, a
// position on the widget itself covers a wider range than 0-1,
// actually it ranges from 0 to 1/(1-size).
void
Fl_Eq::draw_bg(int x, int y, int w, int h)
{
if (!(damage() & FL_DAMAGE_ALL)) { // not a complete redraw
draw_box();
}
Fl_Color black = active_r()? FL_BLACK : FL_INACTIVE_COLOR;
if (type() == FL_VERT_NICE_SLIDER) {
draw_box(FL_THIN_DOWN_BOX, x + w / 2 - 2, y, 4, h, black);
} else if (type() == FL_HOR_NICE_SLIDER) {
draw_box(FL_THIN_DOWN_BOX, x, y + h / 2 - 2, w, 4, black);
}
}
void
Fl_Eq::draw(int x, int y, int w, int h)
{
double val;
if (minimum() == maximum())
val = 0.5;
else {
val = (value() - minimum()) / (maximum() - minimum());
if (val > 1.0)
val = 1.0;
else if (val < 0.0)
val = 0.0;
}
int W = (horizontal()? w : h);
int X, S;
if (type() == FL_HOR_FILL_SLIDER || type() == FL_VERT_FILL_SLIDER) {
S = int (val * W + .5);
if (minimum() > maximum()) {
S = W - S;
X = W - S;
} else
X = 0;
} else {
S = int (slider_size_ * W + .5);
int T = (horizontal()? h : w) / 2 + 1;
if (type() == FL_VERT_NICE_SLIDER || type() == FL_HOR_NICE_SLIDER)
T += 4;
if (S < T)
S = T;
X = int (val * (W - S) + .5);
}
int xsl, ysl, wsl, hsl;
if (horizontal()) {
xsl = x + X;
wsl = S;
ysl = y;
hsl = h;
} else {
ysl = y + X;
hsl = S;
xsl = x;
wsl = w;
}
if (damage() & FL_DAMAGE_ALL) { // complete redraw
draw_bg(x, y, w, h);
} else { // partial redraw, clip off new position of slider
//fl_clip(x, y, w, Fl::event_y());
// draw_bg(x, y, w, h);
// fl_pop_clip();
if (X > 0) {
if (horizontal())
fl_clip(x, ysl, X, hsl);
else
fl_clip(xsl, y, wsl, hsl);
draw_bg(x, y, w, h);
fl_pop_clip();
}
if (X + S < W) {
if (horizontal()) {
fl_clip(xsl + wsl, ysl, x + w - xsl - wsl, hsl);
} else {
if (type() == 2)
fl_clip(xsl, y, wsl, Fl::event_y());
else
fl_clip(xsl, ysl + hsl, wsl, y + h - ysl - hsl);
}
draw_bg(x, y, w, h);
fl_pop_clip();
}
}
Fl_Boxtype box1 = slider();
if (!box1) {
box1 = (Fl_Boxtype) (box() & -2);
if (!box1)
box1 = FL_UP_BOX;
}
if (type() == FL_VERT_NICE_SLIDER) {
draw_box(box1, xsl, ysl, wsl, hsl, FL_GRAY);
int d = (hsl - 4) / 2;
draw_box(FL_THIN_DOWN_BOX, xsl + 2, ysl + d, wsl - 4, hsl - 2 * d,
selection_color());
} else if (type() == FL_HOR_NICE_SLIDER) {
draw_box(box1, xsl, ysl, wsl, hsl, FL_GRAY);
int d = (wsl - 4) / 2;
draw_box(FL_THIN_DOWN_BOX, xsl + d, ysl + 2, wsl - 2 * d, hsl - 4,
selection_color());
} else { // draw the slider box
#ifdef PDA
Fl_Color col = selection_color();
if (horizontal()) {
slider_ver_lines(xsl, ysl, wsl, hsl, W, col);
} else {
slider_hor_lines(xsl, ysl, wsl, hsl, W, col);
}
#else
if (wsl > 0 && hsl > 0)
draw_box(box1, xsl, ysl, wsl, hsl, selection_color());
#endif
}
draw_label(xsl, ysl, wsl, hsl);
}
void
Fl_Eq::draw()
{
if (damage() & FL_DAMAGE_ALL)
draw_box();
draw(x() + Fl::box_dx(box()),
y() + Fl::box_dy(box()),
w() - Fl::box_dw(box()), h() - Fl::box_dh(box()));
}
int
Fl_Eq::handle(int event, int x, int y, int w, int h)
{
if (event == FL_PUSH)
switch (event) {
case FL_PUSH:
if (!Fl::event_inside(x, y, w, h))
return 0;
handle_push();
case FL_DRAG:{
int W = (horizontal()? w : h);
//int H = (horizontal() ? h : w);
int mx =
(horizontal()? Fl::event_x() - x : Fl::event_y() - y);
int S = int (slider_size_ * W + .5);
int X;
static int offcenter;
if (type() == FL_HOR_FILL_SLIDER
|| type() == FL_VERT_FILL_SLIDER) {
double val =
(value() - minimum()) / (maximum() - minimum());
if (val >= 1.0)
X = W;
else if (val <= 0.0)
X = 0;
else
X = int (val * W + .5);
if (event == FL_PUSH) {
offcenter = mx - X;
if (offcenter < -S / 2)
offcenter = 0;
else if (offcenter > S / 2)
offcenter = 0;
else
return 1;
}
S = 0;
} else {
double val =
(value() - minimum()) / (maximum() - minimum());
if (val >= 1.0)
X = W - S;
else if (val <= 0.0)
X = 0;
else
X = int (val * (W - S) + .5);
if (event == FL_PUSH) {
offcenter = mx - X;
if (offcenter < 0)
offcenter = 0;
else if (offcenter > S)
offcenter = S;
else
return 1;
}
}
X = mx - offcenter;
double v;
TRY_AGAIN:
if (X < 0) {
X = 0;
offcenter = mx;
if (offcenter < 0)
offcenter = 0;
} else if (X > (W - S)) {
X = W - S;
offcenter = mx - X;
if (offcenter > S)
offcenter = S;
}
v = round(X * (maximum() - minimum()) / (W - S) + minimum());
// make sure a click outside the sliderbar moves it:
if (event == FL_PUSH && v == value()) {
offcenter = S / 2;
event = FL_DRAG;
goto TRY_AGAIN;
}
handle_drag(clamp(v));
}
return 1;
case FL_RELEASE:
handle_release();
return 1;
default:
return 0;
}
return 0;
}
int
Fl_Eq::handle(int event)
{
return handle(event,
x() + Fl::box_dx(box()),
y() + Fl::box_dy(box()),
w() - Fl::box_dw(box()), h() - Fl::box_dh(box()));
}
--- NEW FILE: xplay.h ---
/* Sound Player (X-interface)
Portions Copyright (C) 2002 Century Embedded Technologies
Copyright (C) 1997 by Woo-jae Jung */
#include <mpegsound.h>
#define MAXFRAMESLIDER 2000
// Strings used frequently
extern char *stopstring, *nonestring, *nullstring;
//
// Functions.cc
//
extern bool exitwhendone;
//
// Xplay.cc
//
// frame managemant
void Setframe(int frame);
int getslidernumber(int frame, int maxframe);
// misc
bool getquotaflag(void);
void setquotaflag(bool flag);
// start up function
void *_startup(void *);
--- NEW FILE: comm.h ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef COMM_H
#define COMM_H
//
// Communication between threads. This is ugly and not thought out at
// all, but seems to work OK.
//
#include <pthread.h>
#include <FL/Fl_Window.H>
//#include <iostream.h>
#include <string.h>
// Client DSP plug-ins definitions
#define FEEDBACK 1
class class_music
{
public:
bool pause, quit;
bool setframeflag;
int setframenumber;
};
class class_musics
{
struct feedback_struct
{
int Hz;
int SR;
Fl_Window *parent;
};
struct playlist_struct
{
int key;
char *title;
char *path;
};
public:
class_musics();
~class_musics();
public:
bool stop;
bool restart;
int move, currentrun;
pthread_mutex_t movelock;
bool errorflag;
int errorcode;
// comm area for xplay to communicate to fltk widgets
int volumeflag;
int newvolume;
int updatestats;
int version;
int layer;
int freq;
int bitrate;
int pcmperframe;
int currentframe;
int maxframe;
char filename[1024]; // disgusting hack to accept mp3 file on cmd line
int tracksplayed; // disgusting hack to play multiple files
char title[1024];
char ch_bitrate[64];
char ch_freq[64];
char *song;
feedback_struct *feedback;
int dsp;
void AddPlayList(char *title, char *path);
void DelPlayList(int index);
int SearchPlayList(char *title);
char *GetPlayListPath(int index)
{
return playlist[index].path;
}
void SetParent(Fl_Window * o);
Fl_Window *GetParent();
void Setcurrentmpegstatus(int ver, int ly, int fr, int bit, char *t)
{
updatestats = 1;
version = ver;
layer = ly;
freq = fr;
bitrate = bit;
strcpy(title, t);
}
private:
playlist_struct * playlist; // Play List
int add_index; // index to add new song to playlist
int play_index; // index for next song to play
Fl_Window *parent;
};
/**********************/
/* Setting music flag */
/**********************/
// Control music
void music_done(void);
bool music_isstop(void);
bool music_ispause(void);
void music_restart(void);
void music_stop(void);
void music_play(void);
void music_pause(void);
void music_unpause(void);
void music_previous(void);
void music_next(void);
// Client Play List
void SetPlayList(char *newSong);
char *GetPlayList();
// Client DSP access points
void SetParent(Fl_Window * o);
Fl_Window *GetParent();
void SetDsp(int newDsp);
int GetDsp();
void *GetArgs();
extern void *dsp_rawdata;
inline void
SetDspData(void *next_rawdata)
{
dsp_rawdata = next_rawdata;
}
inline void *
GetDspData()
{
return dsp_rawdata;
}
#endif
--- NEW FILE: mp3_button.cc ---
/*
* Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*
* This file is part of the PIXIL Operating Environment
*
* The use, copying and distribution of this file is governed by one
* of two licenses, the PIXIL Commercial License, or the GNU General
* Public License, version 2.
*
* Licensees holding a valid PIXIL Commercial License may use this file
* in accordance with the PIXIL Commercial License Agreement provided
* with the Software. Others are governed under the terms of the GNU
* General Public License version 2.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free
* Software Foundation and appearing in the file LICENSE.GPL included
* in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* RESTRICTED RIGHTS LEGEND
*
* Use, duplication, or disclosure by the government is subject to
* restriction as set forth in paragraph (b)(3)(b) of the Rights in
* Technical Data and Computer Software clause in DAR 7-104.9(a).
*
* See http://www.pixil.org/gpl/ for GPL licensing
* information.
*
* See http://www.pixil.org/license.html or
* email cetsales at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include <fspl_panel.h>
#include <stdio.h>
mp3_button::mp3_button(int x, int y, int w, int h, int type):
NxButton(x, y, w, h)
{
type_ = type;
}
void
mp3_button::draw(void)
{
NxButton::draw();
int center_x = x() + w() / 2;
int center_y = y() + h() / 2;
if (value()) {
fl_color(contrast(color(), labelcolor()));
if (type_ == MP3_FORWARD) {
fl_begin_polygon();
fl_transformed_vertex(center_x, center_y - 3);
fl_transformed_vertex(center_x + 5, center_y + 2);
fl_transformed_vertex(center_x, center_y + 7);
fl_end_polygon();
fl_begin_polygon();
fl_transformed_vertex(center_x - 5, center_y - 3);
fl_transformed_vertex(center_x, center_y + 2);
fl_transformed_vertex(center_x - 5, center_y + 7);
fl_end_polygon();
} else if (type_ == MP3_BACK) {
fl_begin_polygon();
fl_transformed_vertex(center_x, center_y - 3);
fl_transformed_vertex(center_x - 5, center_y + 2);
fl_transformed_vertex(center_x, center_y + 7);
fl_end_polygon();
fl_begin_polygon();
fl_transformed_vertex(center_x + 5, center_y - 3);
fl_transformed_vertex(center_x, center_y + 2);
fl_transformed_vertex(center_x + 5, center_y + 7);
fl_end_polygon();
} else if (type_ == MP3_PLAY) {
fl_begin_polygon();
fl_transformed_vertex(center_x - 3, center_y - 3);
fl_transformed_vertex(center_x + 2, center_y + 2);
fl_transformed_vertex(center_x - 3, center_y + 7);
fl_end_polygon();
} else if (type_ == MP3_STOP) {
//fl_rectf(center_x - 14, center_y - 1, 3, 8);
//fl_rectf(center_x - 8, center_y - 1, 3, 8);
//fl_line(center_x - 1, center_y + 5, center_x + 1, center_y - 1);
fl_rectf(center_x - 4, center_y - 1, 8, 8);
} else if (type_ == MP3_PAUSE) {
fl_rectf(center_x - 4, center_y - 1, 3, 8);
fl_rectf(center_x + 1, center_y - 1, 3, 8);
} else {
printf("Unknown MP3_Button type!\n");
}
} else {
fl_color(labelcolor());
if (type_ == MP3_FORWARD) {
fl_begin_polygon();
fl_transformed_vertex(center_x, center_y - 5);
fl_transformed_vertex(center_x + 5, center_y);
fl_transformed_vertex(center_x, center_y + 5);
fl_end_polygon();
fl_begin_polygon();
fl_transformed_vertex(center_x - 5, center_y - 5);
fl_transformed_vertex(center_x, center_y);
fl_transformed_vertex(center_x - 5, center_y + 5);
fl_end_polygon();
} else if (type_ == MP3_BACK) {
fl_begin_polygon();
fl_transformed_vertex(center_x, center_y - 5);
fl_transformed_vertex(center_x - 5, center_y);
fl_transformed_vertex(center_x, center_y + 5);
fl_end_polygon();
fl_begin_polygon();
fl_transformed_vertex(center_x + 5, center_y - 5);
fl_transformed_vertex(center_x, center_y);
fl_transformed_vertex(center_x + 5, center_y + 5);
fl_end_polygon();
} else if (type_ == MP3_PLAY) {
fl_begin_polygon();
fl_transformed_vertex(center_x - 3, center_y - 5);
fl_transformed_vertex(center_x + 2, center_y);
fl_transformed_vertex(center_x - 3, center_y + 5);
fl_end_polygon();
} else if (type_ == MP3_STOP) {
//fl_rectf(center_x - 14, center_y - 3, 3, 8);
//fl_rectf(center_x - 8, center_y - 3, 3, 8);
//fl_line(center_x - 1, center_y + 3, center_x + 1, center_y - 3);
fl_rectf(center_x - 4, center_y - 3, 8, 8);
} else if (type_ == MP3_PAUSE) {
fl_rectf(center_x - 4, center_y - 3, 3, 8);
fl_rectf(center_x + 1, center_y - 3, 3, 8);
} else {
printf("Unkown MP3_Button type!\n");
}
}
}
mp3_button::~mp3_button()
{
}
More information about the dslinux-commit
mailing list