|
|
|
@ -185,7 +185,7 @@ tdemidClient::tdemidClient(TQWidget *parent, TDEActionCollection *ac, const char
|
|
|
|
|
tdeconf->setGroup("Midimapper");
|
|
|
|
|
TQCString qs=TQFile::encodeName(tdeconf->readPathEntry("Loadfile","gm.map"));
|
|
|
|
|
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Read Config file: %s\n",qs.data());
|
|
|
|
|
#endif
|
|
|
|
|
setMidiMapFilename(qs.data());
|
|
|
|
@ -321,7 +321,7 @@ int tdemidClient::openFile(const char *filename)
|
|
|
|
|
if (midifile_opened) delete midifile_opened;
|
|
|
|
|
midifile_opened=new char[strlen(filename)+1];
|
|
|
|
|
strcpy(midifile_opened,filename);
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("TOTAL TIME: %g milliseconds\n",player->information()->millisecsTotal);
|
|
|
|
|
#endif
|
|
|
|
|
// noteArray=player->parseNotes();
|
|
|
|
@ -530,7 +530,7 @@ void tdemidClient::slotPlay()
|
|
|
|
|
m_kMid.pctl->error=0;
|
|
|
|
|
m_kMid.pctl->SPEVplayed=0;
|
|
|
|
|
m_kMid.pctl->SPEVprocessed=0;
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
passcount=0;
|
|
|
|
|
#endif
|
|
|
|
|
noteArray->iteratorBegin();
|
|
|
|
@ -538,11 +538,11 @@ void tdemidClient::slotPlay()
|
|
|
|
|
TQApplication::flushX();
|
|
|
|
|
if ((m_kMid.pid=fork())==0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("PlayerProcessID: %d\n",getpid());
|
|
|
|
|
#endif
|
|
|
|
|
player->play(0,(void (*)(void))tdemidOutput);
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("End of child process\n");
|
|
|
|
|
#endif
|
|
|
|
|
_exit(0);
|
|
|
|
@ -551,7 +551,7 @@ void tdemidClient::slotPlay()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spev=player->specialEvents();
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("writing SPEV\n");
|
|
|
|
|
player->debugSpecialEvents();
|
|
|
|
|
printf("writing SPEV(END)\n");
|
|
|
|
@ -569,7 +569,7 @@ void tdemidClient::slotPlay()
|
|
|
|
|
|
|
|
|
|
timer4timebar->start(1000);
|
|
|
|
|
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("PlayerProcess: %d . ParentProcessID: %d\n",m_kMid.pid,getpid());
|
|
|
|
|
printf("******************************-\n");
|
|
|
|
|
#endif
|
|
|
|
@ -620,7 +620,7 @@ void tdemidClient::slotSeek(int i)
|
|
|
|
|
if (m_kMid.pid!=0)
|
|
|
|
|
{
|
|
|
|
|
kill(m_kMid.pid,SIGTERM);
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Waiting for Process %d to be killed\n",m_kMid.pid);
|
|
|
|
|
#endif
|
|
|
|
|
waitpid(m_kMid.pid, NULL, 0);
|
|
|
|
@ -630,7 +630,7 @@ void tdemidClient::slotSeek(int i)
|
|
|
|
|
allNotesOff();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("change Time: %d\n",i);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -648,13 +648,13 @@ void tdemidClient::slotSeek(int i)
|
|
|
|
|
TQApplication::flushX();
|
|
|
|
|
if ((m_kMid.pid=fork())==0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Player_ProcessID: %d\n",getpid());
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
player->play(0,(void (*)(void))tdemidOutput);
|
|
|
|
|
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("End of child process\n");
|
|
|
|
|
#endif
|
|
|
|
|
_exit(0);
|
|
|
|
@ -687,7 +687,7 @@ void tdemidClient::slotSeek(int i)
|
|
|
|
|
|
|
|
|
|
void tdemidClient::moveEventPointersTo(ulong ms)
|
|
|
|
|
{
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Move To: %lu\n",ms);
|
|
|
|
|
#endif
|
|
|
|
|
spev=player->specialEvents();
|
|
|
|
@ -812,7 +812,7 @@ void tdemidClient::slotNextSong()
|
|
|
|
|
int r;
|
|
|
|
|
while ((r=1+(int) ((double)(currentsl->NumberOfSongs())*rand()/(RAND_MAX+1.0)))==currentsl->getActiveSongID()) ;
|
|
|
|
|
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("random number:%d\n",r);
|
|
|
|
|
#endif
|
|
|
|
|
currentsl->setActiveSong(r);
|
|
|
|
@ -838,7 +838,7 @@ void tdemidClient::slotNextSong()
|
|
|
|
|
void tdemidClient::slotPause()
|
|
|
|
|
{
|
|
|
|
|
if (m_kMid.pctl->playing==0) return;
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("song Pause\n");
|
|
|
|
|
#endif
|
|
|
|
|
if (m_kMid.pctl->paused==0)
|
|
|
|
@ -869,11 +869,11 @@ void tdemidClient::slotPause()
|
|
|
|
|
TQApplication::flushX();
|
|
|
|
|
if ((m_kMid.pid=fork())==0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("PlayerProcessID: %d\n",getpid());
|
|
|
|
|
#endif
|
|
|
|
|
player->play(0,(void (*)(void))tdemidOutput);
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("End of child process\n");
|
|
|
|
|
#endif
|
|
|
|
|
_exit(0);
|
|
|
|
@ -938,13 +938,13 @@ void tdemidClient::slotStop()
|
|
|
|
|
if (m_kMid.pctl->playing==0) return;
|
|
|
|
|
|
|
|
|
|
if (m_kMid.pctl->paused) return;
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("song Stop\n");
|
|
|
|
|
#endif
|
|
|
|
|
if (m_kMid.pid!=0)
|
|
|
|
|
{
|
|
|
|
|
kill(m_kMid.pid,SIGTERM);
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Killing\n");
|
|
|
|
|
#endif
|
|
|
|
|
waitpid(m_kMid.pid, NULL, 0);
|
|
|
|
@ -1015,7 +1015,7 @@ void tdemidClient::tdemidOutput(void)
|
|
|
|
|
char *text=new char[ev->length+1];
|
|
|
|
|
strncpy(text,(char *)ev->data,ev->length);
|
|
|
|
|
text[ev->length]=0;
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("%s , played at: %ld\n",text,currentmillisec-beginmillisec);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -1040,7 +1040,7 @@ void tdemidClient::processSpecialEvent()
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//#ifdef KMidDEBUG
|
|
|
|
|
//#ifdef TDEMidDEBUG
|
|
|
|
|
// printf(":::: %ld",passcount++);
|
|
|
|
|
// printf("%d %s %ld",spev->type,spev->text,spev->absmilliseconds);
|
|
|
|
|
//#endif
|
|
|
|
@ -1071,7 +1071,7 @@ void tdemidClient::processSpecialEvent()
|
|
|
|
|
else if (spev->type==3)
|
|
|
|
|
{
|
|
|
|
|
tempoLCD->display(tempoToMetronomeTempo(spev->tempo));
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Changing lcd tempo: spev->tempo: %d , ratio: %.9g\n",spev->tempo,m_kMid.pctl->ratioTempo);
|
|
|
|
|
printf("Result: %g %.9g %d\n",tempoToMetronomeTempo(spev->tempo),tempoToMetronomeTempo(spev->tempo),(int)tempoToMetronomeTempo(spev->tempo));
|
|
|
|
|
#endif
|
|
|
|
@ -1084,7 +1084,7 @@ void tdemidClient::processSpecialEvent()
|
|
|
|
|
}
|
|
|
|
|
else if (spev->type==7)
|
|
|
|
|
{
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Beat: %d/%d\n",spev->num,spev->den);
|
|
|
|
|
#endif
|
|
|
|
|
rhythmview->Beat(spev->num);
|
|
|
|
@ -1255,7 +1255,7 @@ void tdemidClient::slotSelectSong(int i)
|
|
|
|
|
i++;
|
|
|
|
|
if ((i<=0)) // The collection may be empty, or it may be just a bug :-)
|
|
|
|
|
{
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Empty\n");
|
|
|
|
|
#endif
|
|
|
|
|
emit stopPause();
|
|
|
|
@ -1323,7 +1323,7 @@ void tdemidClient::setCollectionPlayMode(int i)
|
|
|
|
|
void tdemidClient::saveCollections(void)
|
|
|
|
|
{
|
|
|
|
|
if (slman==NULL) return;
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Saving collections in: %s\n",collectionsfile.ascii());
|
|
|
|
|
#endif
|
|
|
|
|
slman->saveConfig(TQFile::encodeName(collectionsfile));
|
|
|
|
@ -1450,7 +1450,7 @@ void tdemidClient::slotSetTempo(double value)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("Change tempo to %g\n",value);
|
|
|
|
|
#endif
|
|
|
|
|
int autocontplaying=0;
|
|
|
|
@ -1471,7 +1471,7 @@ void tdemidClient::slotSetTempo(double value)
|
|
|
|
|
sprintf(s,"%g",ratio);
|
|
|
|
|
if (strcmp(s,"1")!=0) tempoLCD->setLCDColor (255,100,100);
|
|
|
|
|
else tempoLCD->setLCDColor (100,255,100);
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("ratio: (%.9g = %g ) tempo now: %g , new tempo %g\n",ratio,ratio,tempoToMetronomeTempo(m_kMid.pctl->tempo),value);
|
|
|
|
|
printf("OldValue: %g , value %g\n",tempoLCD->getOldValue(),value);
|
|
|
|
|
#endif
|
|
|
|
@ -1479,7 +1479,7 @@ void tdemidClient::slotSetTempo(double value)
|
|
|
|
|
if (m_kMid.pctl->paused==1)
|
|
|
|
|
{
|
|
|
|
|
pausedatmillisec=(long)(((double)pausedatmillisec/m_kMid.pctl->ratioTempo)*ratio);
|
|
|
|
|
#ifdef KMidDEBUG
|
|
|
|
|
#ifdef TDEMidDEBUG
|
|
|
|
|
printf("pausedat: %ld\n",pausedatmillisec);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|