📄 track_g36.c
字号:
/* * track_g36.cc * Copyright (C) 1998-2000 SAKAI Katsuya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <stdio.h> // #include <iostream.h>#include <unistd.h>#include "config.h"#include "extern.h"#include "recomposer.h"#include "queue.h"#include "defines.h"inline void G36_Track::NextRecord(){ Index += 6;}inline int G36_Track::Step(){ return (int)((Data[Index+3]<<8)|(Data[Index+2]));}inline int G36_Track::Gate(){ return (int)Data[Index+4];} inline int G36_Track::Vel(){ return (int)Data[Index+1];}void G36_Track::NoteOn(){ u_char cmd, note; Event *Noff_Event; if(Mode!=MUTE && Gate()!=0 && Vel()!=0 && Mute!=TRUE) { cmd = Channel | 0x90; if(Key_Bias & KEY_OFF) { note = EVENT; } else { note=(EVENT+Header->PlayBIAS+Key_Bias)&0x7f; } if(N_ON[note]==0) { aSequencer->midiEvent2(Port, cmd, (u_char)note, Vel()); } N_ON[note]++; Noff_Event = new Event; Noff_Event->Track = Number-1; Noff_Event->Time = TotalStep + (u_long)((Data[Index+5]<<8)|Data[Index+4])-Step(); Noff_Event->Type = EV_NOTE_OFF; Noff_Event->Channel = Channel; Noff_Event->Note = note; Noff_Event->Port = Port; Noff_Queue->store(Noff_Event); #ifdef SHOW_EVENT cout << hex << (int)cmd << " " << dec << (int)note << ' ' << (int)Vel() << " " << (int)N_ON[note] << " NoteOff:"<<Noff_Event->Time << endl;#endif }#ifdef SHOW_EVENT else cout << "rest" << endl;#endif NextRecord();}void G36_Track::TrackExclusive(){ int ExEndFlag=FALSE; int sum=0, exlen=0; u_char ex[512], ExData[5];#ifdef RUNNING_ST aSequencer->clearStatus(Port);#endif ex[exlen++] = 0xF0; #ifdef SHOW_EVENT cout << hex << " F0 ";#endif int i, len; len=6; while(1) { ExData[0]=Data[Index+len+1]; ExData[1]=Data[Index+len+2]; ExData[2]=Data[Index+len+3]; ExData[3]=Data[Index+len+4]; ExData[4]=Data[Index+len+5]; for(i=0;i<5;i++) { if(ExEndFlag==FALSE) switch(ExData[i]) { case 0x80: ex[exlen++] = Gate(); sum+=(int)Gate();#ifdef SHOW_EVENT cout << (int)Gate() << ' ';#endif break; case 0x81: ex[exlen++] = Vel(); sum+=(int)Vel();#ifdef SHOW_EVENT cout << (int)Vel() << ' ';#endif break; case 0x82: ex[exlen++] = Channel; sum+=(int)Channel;#ifdef SHOW_EVENT cout << (int)Channel << ' ';#endif break; case 0x83: sum = 0; break; case 0x84: ex[exlen++] = (0x0 - sum)&0x7F;#ifdef SHOW_EVENT cout << (int)((0x0 - sum)&0x7F) << ' ';#endif sum += ((0x0 - sum)&0x7F); break; case 0xF7: ExEndFlag=TRUE; break; default: ex[exlen++] = ExData[i];#ifdef SHOW_EVENT cout << (int)ExData[i] << ' ';#endif sum += ExData[i]; break; } } if(Data[Index+len+6]!=0xF7) { break; } len+=6; } ex[exlen++] = 0xF7; aSequencer->send_exclusive (Port, ex, exlen); Index += (len+6); # ifdef SHOW_EVENT cout << "F7 ChExclusive" << endl;# endif}void G36_Track::CommentProc(){ int len=6, i=0, j; char str[256]; while(1) { if(Data[Index+len]!=0xF7) break; for (j=1;j<=5;j++) str[i++] = Data[Index+len+j]; len+=6; } aSequencer->metaEvent (1, i, str); Index += len; # ifdef SHOW_EVENT cout << "Comment:" << str << endl;# endif}void G36_Track::SameMeasure(){ static u_long idx; if(SameMeasureFlag==ON) { Index = SameMeasurePtr; SameMeasureFlag=OFF; NextRecord(); } else { SameMeasurePtr=Index; SameMeasureFlag=ON; do { # ifdef SHOW_EVENT if(Version==V_G36_WIN) cout << dec <<(long)((Data[Index+5]<<8)|Data[Index+4])*6-288L<<" "; else cout << dec <<(long)((Data[Index+5]<<8)|Data[Index+4])-46L <<" ";# endif if(Version==V_G36_WIN) idx = (u_long)((Data[Index+5]<<8)|Data[Index+4])*6-288L; else idx = (u_long)((Data[Index+5]<<8)|Data[Index+4])-46L; if (idx<Index) Index = idx; else { SameMeasureFlag = OFF; Index = SameMeasurePtr; NextRecord(); TotalStep += aSequencer->show_timebase () * aSequencer->show_timebase () * Header->TimeSignature[0] * 4 / Header->TimeSignature[1]; } } while(EVENT==0xFC && SameMeasureFlag==ON); } # ifdef SHOW_EVENT cout << "SameMeasure" << endl;# endif}void G36_Track::TempoChange(){ aSequencer->set_tempo (60*1000000/(Header->Tempo * ((Data[Index+4]&0xFF)+((Data[Index+5]&0xFF)<<8))/64)); # ifdef SHOW_TEMPO cout << dec <<"Track:" << (int)Number << " Index:" << Index << " MasterTempo:" << Header->Tempo << " Gate:" << Gate() << ' ' << (int)Data[Index+5] <<" Tempo:" << (Header->Tempo*((Data[Index+4]&0xFF)+ ((Data[Index+5]&0xFF)<<8))/64) << endl;#endif NextRecord();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -