test_music.c
3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*************************************************************
test_music.c : Nintendo 64 Music Tools Library Sample
(c) Copyright 1998, Software Creations (Holdings) Ltd.
Version 3.11
N64DD demo music related source file.
**************************************************************/
/* include system header files */
#ifndef F3DEX_GBI
#define F3DEX_GBI
#endif
#include <ultra64.h>
#include <leo.h>
#include <libmus.h>
/* include application main header file */
#include "test_rom.h"
/* include application specific header files */
#include "test_n64dd.h" /* disk access functions */
#include "test_mem.h" /* memory manager functions */
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
[GLOBAL FUNCTION]
InitMusicDriver()
[Explantion]
Download ROM files and initialise the music player.
[Return value]
NONE
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
/* 'makerom' generated labels */
/* ROM addresses */
#define DISKWBANK_START _wbankSegmentDiskStart
#define DISKWBANK_END _wbankSegmentDiskEnd
#define DISKPBANK_START _pbankSegmentDiskStart
#define DISKPBANK_END _pbankSegmentDiskEnd
#define DISKMUSIC_START _tuneSegmentDiskStart
#define DISKMUSIC_END _tuneSegmentDiskEnd
#ifdef __GNUC__
extern short int DISKWBANK_START;
extern short int DISKWBANK_END;
extern short int DISKPBANK_START;
extern short int DISKPBANK_END;
extern short int DISKMUSIC_START;
extern short int DISKMUSIC_END;
#else
extern char DISKWBANK_START[];
extern char DISKWBANK_END[];
extern char DISKPBANK_START[];
extern char DISKPBANK_END[];
extern char DISKMUSIC_START[];
extern char DISKMUSIC_END[];
#endif
/* permanent RAM buffers */
#define AUDIO_HEAP_SIZE 300000
/* memory buffers claimed from application heap */
unsigned char *audio_heap;
unsigned char *pointer_buffer;
unsigned char *sample_buffer;
unsigned char *tune_buffer;
void InitMusicDriver(void)
{
musConfig init;
/* allocate memory for audio heap */
audio_heap = MemMalloc(AUDIO_HEAP_SIZE);
/* allocate and read sample .ptr file */
pointer_buffer = MemMalloc(DiskSize(DISKPBANK_START, DISKPBANK_END));
DiskRead(DISKPBANK_START, DISKPBANK_END, pointer_buffer);
/* allocate and read sample .wbk file */
sample_buffer = MemMalloc(DiskSize(DISKWBANK_START, DISKWBANK_END));
DiskRead(DISKWBANK_START, DISKWBANK_END, sample_buffer);
/* allocate and read song .bin file */
tune_buffer = MemMalloc(DiskSize(DISKPBANK_START, DISKPBANK_END));
DiskRead(DISKMUSIC_START, DISKMUSIC_END, tune_buffer);
/* setup configuration structure */
init.control_flag = MUSCONTROL_RAM; /* samples will be RAM based */
init.channels = 16;
init.sched = ≻
init.thread_priority = 12;
init.heap = audio_heap;
init.heap_length = AUDIO_HEAP_SIZE;
init.fifo_length = 64;
init.ptr = pointer_buffer;
init.wbk = sample_buffer;
init.default_fxbank = NULL;
init.syn_output_rate = 32000;
init.syn_updates = 256;
init.syn_rsp_cmds = 4096;
init.syn_retraceCount= 1;
init.syn_num_dma_bufs= 36;
init.syn_dma_buf_size= 0x800;
// Special Addition for DDROM
init.diskrom_handle = osDriveRomInit();
MusInitialize(&init);
}
/* end of file */