Commit efff0d5be49e438aefc3460617744c5e1dd1be61
Updated playerGetInfo with a few more things. Example player can now select subtunes, oh yay.
anonymous authored on 1/2/2016, 9:12:41 PMChristopher Snowhill committed on 6/13/2018, 12:10:58 AM
Parent: e53977afa504fe961bd61e048e74d6ddd0f598b3
Files changed
src/main.c | changed |
src/syntrax/syntrax.c | changed |
src/syntrax/syntrax.h | changed |
src/main.c | ||
---|---|---|
@@ -8,8 +8,9 @@ | ||
8 | 8 | |
9 | 9 | |
10 | 10 | |
11 | 11 | |
12 | + | |
12 | 13 | |
13 | 14 | |
14 | 15 | |
15 | 16 | |
@@ -20,8 +21,9 @@ | ||
20 | 21 | char audiobuffer[BUFFNUM][((44100*2*2)/50)]; |
21 | 22 | |
22 | 23 | Song *sang = NULL; |
23 | 24 | Player *player = NULL; |
25 | +syntrax_info info; | |
24 | 26 | |
25 | 27 | HANDLE eventh; |
26 | 28 | |
27 | 29 | void pressAny(void) { |
@@ -71,48 +73,96 @@ | ||
71 | 73 | //if( synSong ) free( synSong ); |
72 | 74 | if( hWaveOut != INVALID_HANDLE_VALUE ) waveOutClose( hWaveOut ); |
73 | 75 | } |
74 | 76 | |
77 | +void updateScreen(void) | |
78 | +{ | |
79 | + playerGetInfo(player, &info); | |
80 | + //cls is expensive and I am lazy | |
81 | + //we can't put this in the loop | |
82 | + system("cls"); | |
83 | + printf("Syntrax test player v0.0001 || %i/%i \n", info.selectedSubs+1, info.totalSubs); | |
84 | + printf("Title: %s\n", info.subsongName); | |
85 | +} | |
86 | + | |
75 | 87 | int main(int argc, char *argv[]) |
76 | 88 | { |
77 | 89 | WAVEHDR header[BUFFNUM]; |
78 | 90 | int nextbuf = 0; |
79 | 91 | //sigset_t base_mask, waiting_mask; |
80 | 92 | |
81 | - printf( "Syntrax test player v0.000000001\n" ); | |
82 | - | |
83 | 93 | if( argc < 2 ) |
84 | 94 | { |
85 | 95 | printf( "Usage: syntrax-c <tune.jxs>\n" ); |
96 | + printf( "[ and ] keys change subtune.\n" ); | |
97 | + printf( "\n" ); | |
98 | + system("pause"); | |
86 | 99 | return 0; |
87 | 100 | } |
88 | 101 | |
89 | 102 | if( init( argv[1] ) ) |
90 | 103 | { |
91 | 104 | int i; |
105 | + updateScreen(); | |
92 | 106 | |
93 | 107 | for ( i=0; i<BUFFNUM; i++ ){ |
94 | 108 | memset( &header[i], 0, sizeof( WAVEHDR ) ); |
95 | 109 | header[i].dwBufferLength = ((44100*2*2)/50); |
96 | 110 | header[i].lpData = (LPSTR)audiobuffer[i]; |
97 | 111 | } |
98 | 112 | for ( i=0; i<BUFFNUM-1; i++ ){ |
99 | - mixChunk(player, audiobuffer[nextbuf], 44100/50); | |
113 | + mixChunk(player, audiobuffer[nextbuf], 882); | |
100 | 114 | waveOutPrepareHeader( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) ); |
101 | 115 | waveOutWrite( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) ); |
102 | 116 | nextbuf = (nextbuf+1)%BUFFNUM; |
103 | 117 | } |
104 | - | |
105 | 118 | for(;;) |
106 | 119 | { |
107 | - mixChunk(player, audiobuffer[nextbuf], 44100/50); | |
120 | + mixChunk(player, audiobuffer[nextbuf], 882); | |
108 | 121 | waveOutPrepareHeader( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) ); |
109 | 122 | waveOutWrite( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) ); |
110 | 123 | nextbuf = (nextbuf+1)%BUFFNUM; |
111 | 124 | |
112 | 125 | // Don't do this in your own player or plugin :-) |
113 | 126 | //while( waveOutUnprepareHeader( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) ) == WAVERR_STILLPLAYING ) ; |
114 | 127 | while( waveOutUnprepareHeader( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) ) == WAVERR_STILLPLAYING ){ |
128 | + if (_kbhit()) { | |
129 | + int subnum; | |
130 | + switch (_getch()) { | |
131 | + case 0: /* introduces an extended key */ | |
132 | + case 227: /* this also happens on Win32 (I think) */ | |
133 | + switch (_getch()) { /* read the extended key code */ | |
134 | + case 72: /* up arrow press */ | |
135 | + break; | |
136 | + case 75: /* left arrow press */ | |
137 | + break; | |
138 | + case 77: /* right arrow press */ | |
139 | + break; | |
140 | + case 80: /* down arrow press */ | |
141 | + break; | |
142 | + /* etc */ | |
143 | + } | |
144 | + break; | |
145 | + case '[': | |
146 | + subnum = info.selectedSubs; | |
147 | + --subnum; | |
148 | + if (subnum < 0) subnum = info.totalSubs - 1; | |
149 | + | |
150 | + if (info.selectedSubs != subnum) initSubsong(player, subnum); | |
151 | + updateScreen(); | |
152 | + break; | |
153 | + case ']': | |
154 | + subnum = info.selectedSubs; | |
155 | + subnum = ++subnum % info.totalSubs; | |
156 | + | |
157 | + if (info.selectedSubs != subnum) initSubsong(player, subnum); | |
158 | + updateScreen(); | |
159 | + break; | |
160 | + | |
161 | + case 'H': /* capital 'H' key press */ break; | |
162 | + /* etc */ | |
163 | + } | |
164 | + } | |
115 | 165 | WaitForSingleObject(eventh, INFINITE); |
116 | 166 | } |
117 | 167 | ResetEvent(eventh); |
118 | 168 | } |
src/syntrax/syntrax.c | ||
---|---|---|
@@ -2330,8 +2330,11 @@ | ||
2330 | 2330 | { |
2331 | 2331 | int i, j; |
2332 | 2332 | info->coarse = p->posCoarse; |
2333 | 2333 | info->fine = p->posFine; |
2334 | + memcpy(&info->subsongName, &p->curSubsong.m_Name, 33); | |
2335 | + info->selectedSubs = p->selectedSubsong; | |
2336 | + info->totalSubs = p->synSong->h.subsongNum; | |
2334 | 2337 | for (i = 0, j = 0; i < p->channelNumber; i++) |
2335 | 2338 | { |
2336 | 2339 | Voice *v = &p->voices[i]; |
2337 | 2340 | if (v->waveBuff != p->silentBuffer) |
Built with git-ssb-web