1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - SND - demos - seq 3 File: seq.h 4 5 Copyright 2007-2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2008-09-18#$ 14 $Rev: 8573 $ 15 $Author: okubata_ryoma $ 16 *---------------------------------------------------------------------------*/ 17 #ifndef SEQ_H_ 18 #define SEQ_H_ 19 20 #ifdef SDK_TWL 21 #include <twl.h> 22 #else 23 #include <nitro.h> 24 #endif 25 26 /* Clock interval constant (microseconds) */ 27 #define SEQ_CLOCK_INTERVAL_NITRO_VBLANK 16715 /* NITRO V-blank interval */ 28 29 /* Error codes */ 30 #define SEQ_ERROR_WRONG_HEADER 1 /* Illegal header chunk */ 31 #define SEQ_ERROR_NOT_FORMAT0 2 /* SMF that is not format 0 */ 32 #define SEQ_ERROR_DIVISION_TIMECODE 3 /* SMF division is in time code format */ 33 #define SEQ_ERROR_WRONG_TRACK 4 /* Illegal track chunk */ 34 #define SEQ_ERROR_WRONG_DELTA_TIME 5 /* Variable length value for an illegal delta time */ 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* Sound handle */ 41 typedef struct tSeqHandle 42 { 43 u8 state; /* State */ 44 u8 running_status; /* Running status buffer */ 45 u8 next_delta_bytesize; /* Byte size of the delta time for the next event */ 46 u8 padding1; 47 u16 division; /* SMF resolution */ 48 u16 padding2; 49 u32 tempo; /* Tempo */ 50 u32 time_control; /* Time manager */ 51 u32 time_per_callback; /* Time passed in one callback (tick*microseconds/quarter notes) */ 52 u32 chunk_size; /* Size of data chunk */ 53 u32 total_tick; /* Total number of ticks at the current position counting from the beginning */ 54 u32 delta_time; /* Delta time until the next event */ 55 const u8 *current_ptr; /* Pointer to the current position */ 56 const u8 *track_begin; /* Pointer to the location of the start of a track */ 57 const u8 *loop_begin; /* Pointer to the location of the start of a loop */ 58 } 59 SeqHandle; 60 61 void SeqInit(u32 clock_interval, void (*callback) (const u8 *)); 62 BOOL SeqMain(SeqHandle * block); 63 BOOL SeqPlay(SeqHandle * block, const u8 *smfdata); 64 void SeqStop(SeqHandle * block); 65 void SeqPause(SeqHandle * block); 66 u8 SeqGetErrorCode(void); 67 68 #ifdef __cplusplus 69 } 70 #endif 71 72 #endif // SEQ_H_ 73