Lines Matching refs:handle
86 BOOL SeqMain(SeqHandle * handle) in SeqMain() argument
93 if (!(handle->state & SEQ_STATE_PLAY)) in SeqMain()
99 handle->time_control += handle->time_per_callback; in SeqMain()
101 while (handle->time_control > handle->tempo) in SeqMain()
106 if (handle->delta_time > 0) in SeqMain()
108 handle->delta_time--; in SeqMain()
111 while (handle->delta_time == 0) in SeqMain()
115 handle->current_ptr += handle->next_delta_bytesize; in SeqMain()
118 if (*handle->current_ptr >= 0x80) in SeqMain()
121 current_event = handle->running_status = *handle->current_ptr; in SeqMain()
127 if (handle->running_status < 0x80) in SeqMain()
132 current_event = handle->running_status; in SeqMain()
136 if (*handle->current_ptr == SMF_META) in SeqMain()
140 read_size = SeqExecMetaEvent(handle); in SeqMain()
142 if (handle->state & SEQ_STATE_END) in SeqMain()
145 (void)SeqStop(handle); in SeqMain()
146 handle->state &= ~SEQ_STATE_END; in SeqMain()
149 else if (handle->state & SEQ_STATE_LOOP) in SeqMain()
152 handle->current_ptr = handle->loop_begin; in SeqMain()
153 handle->state &= ~SEQ_STATE_LOOP; in SeqMain()
158 handle->current_ptr += read_size; in SeqMain()
164 if (*handle->current_ptr == SMF_SYSX) in SeqMain()
168 if (SEQ_SYSX_BUFFER_SIZE > handle->current_ptr[1] + 1) in SeqMain()
173 seqSysxBuffer[0] = handle->current_ptr[0]; in SeqMain()
174 for (i = 1; i <= handle->current_ptr[1]; i++) in SeqMain()
176 seqSysxBuffer[i] = handle->current_ptr[i + 1]; in SeqMain()
184 handle->current_ptr += handle->current_ptr[1] + 2; in SeqMain()
191 seq_sys.callback(handle->current_ptr); in SeqMain()
194 handle->current_ptr += in SeqMain()
200 handle->next_delta_bytesize = in SeqMain()
201 SeqReadVariableData(handle->current_ptr, &handle->delta_time); in SeqMain()
202 if (handle->next_delta_bytesize == 0) in SeqMain()
209 handle->total_tick++; in SeqMain()
212 handle->time_control -= handle->tempo; in SeqMain()
226 static u8 SeqExecMetaEvent(SeqHandle * handle) in SeqExecMetaEvent() argument
228 switch (handle->current_ptr[1]) in SeqExecMetaEvent()
231 if (handle->current_ptr[2] != 1) in SeqExecMetaEvent()
237 if (handle->current_ptr[3] == '[') in SeqExecMetaEvent()
240 handle->loop_begin = handle->current_ptr + handle->current_ptr[2] + 3; in SeqExecMetaEvent()
242 else if (handle->current_ptr[3] == ']') in SeqExecMetaEvent()
245 if (handle->loop_begin != NULL) in SeqExecMetaEvent()
247 handle->state |= SEQ_STATE_LOOP; in SeqExecMetaEvent()
252 handle->state |= SEQ_STATE_END; in SeqExecMetaEvent()
255 handle->tempo = handle->current_ptr[3]; in SeqExecMetaEvent()
256 handle->tempo <<= 8; in SeqExecMetaEvent()
257 handle->tempo += handle->current_ptr[4]; in SeqExecMetaEvent()
258 handle->tempo <<= 8; in SeqExecMetaEvent()
259 handle->tempo += handle->current_ptr[5]; in SeqExecMetaEvent()
265 return (u8)(handle->current_ptr[2] + 3); in SeqExecMetaEvent()
278 BOOL SeqPlay(SeqHandle * handle, const u8 *smfdata) in SeqPlay() argument
285 read_size = SeqReadSMFHeader(handle, smfdata); in SeqPlay()
289 handle->current_ptr = smfdata + read_size; in SeqPlay()
295 if (handle->current_ptr[i] != mtrk[i]) in SeqPlay()
301 handle->current_ptr += sizeof(u8) * 4; in SeqPlay()
303 handle->chunk_size = ReverseEndian32(*(u32 *)handle->current_ptr); in SeqPlay()
304 handle->current_ptr += sizeof(u32); in SeqPlay()
307 handle->track_begin = handle->current_ptr; in SeqPlay()
310 handle->tempo = SEQ_DEFAULT_TEMPO; in SeqPlay()
311 handle->time_control = 0; in SeqPlay()
312 handle->time_per_callback = handle->division * seq_sys.clock_interval; in SeqPlay()
313 handle->total_tick = 0; in SeqPlay()
314 handle->running_status = 0x00; in SeqPlay()
315 handle->loop_begin = NULL; in SeqPlay()
318 handle->state = SEQ_STATE_PLAY; in SeqPlay()
321 handle->next_delta_bytesize = SeqReadVariableData(handle->current_ptr, &handle->delta_time); in SeqPlay()
322 if (handle->next_delta_bytesize == 0) in SeqPlay()
340 void SeqStop(SeqHandle * handle) in SeqStop() argument
342 handle->current_ptr = handle->track_begin; in SeqStop()
345 handle->state &= ~SEQ_STATE_PLAY; in SeqStop()
357 void SeqPause(SeqHandle * handle) in SeqPause() argument
360 handle->state &= ~SEQ_STATE_PLAY; in SeqPause()
373 static u8 SeqReadSMFHeader(SeqHandle * handle, const u8 *data) in SeqReadSMFHeader() argument
417 handle->division = ReverseEndian16(*(u16 *)ptr); in SeqReadSMFHeader()
418 if (handle->division >= 0x8000) in SeqReadSMFHeader()