git ssb

0+

kode54 / syntrax-c



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 PM
Christopher Snowhill committed on 6/13/2018, 12:10:58 AM
Parent: e53977afa504fe961bd61e048e74d6ddd0f598b3

Files changed

src/main.cchanged
src/syntrax/syntrax.cchanged
src/syntrax/syntrax.hchanged
src/main.cView
@@ -8,8 +8,9 @@
88 #include <stddef.h>
99
1010 #include <windows.h> // for mixer stream
1111 #include <mmsystem.h> // for mixer stream
12+#include <conio.h> // keyboard input
1213
1314 #include "syntrax\syntrax.h"
1415
1516 #define BUFFNUM 8
@@ -20,8 +21,9 @@
2021 char audiobuffer[BUFFNUM][((44100*2*2)/50)];
2122
2223 Song *sang = NULL;
2324 Player *player = NULL;
25+syntrax_info info;
2426
2527 HANDLE eventh;
2628
2729 void pressAny(void) {
@@ -71,48 +73,96 @@
7173 //if( synSong ) free( synSong );
7274 if( hWaveOut != INVALID_HANDLE_VALUE ) waveOutClose( hWaveOut );
7375 }
7476
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+
7587 int main(int argc, char *argv[])
7688 {
7789 WAVEHDR header[BUFFNUM];
7890 int nextbuf = 0;
7991 //sigset_t base_mask, waiting_mask;
8092
81- printf( "Syntrax test player v0.000000001\n" );
82-
8393 if( argc < 2 )
8494 {
8595 printf( "Usage: syntrax-c <tune.jxs>\n" );
96+ printf( "[ and ] keys change subtune.\n" );
97+ printf( "\n" );
98+ system("pause");
8699 return 0;
87100 }
88101
89102 if( init( argv[1] ) )
90103 {
91104 int i;
105+ updateScreen();
92106
93107 for ( i=0; i<BUFFNUM; i++ ){
94108 memset( &header[i], 0, sizeof( WAVEHDR ) );
95109 header[i].dwBufferLength = ((44100*2*2)/50);
96110 header[i].lpData = (LPSTR)audiobuffer[i];
97111 }
98112 for ( i=0; i<BUFFNUM-1; i++ ){
99- mixChunk(player, audiobuffer[nextbuf], 44100/50);
113+ mixChunk(player, audiobuffer[nextbuf], 882);
100114 waveOutPrepareHeader( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) );
101115 waveOutWrite( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) );
102116 nextbuf = (nextbuf+1)%BUFFNUM;
103117 }
104-
105118 for(;;)
106119 {
107- mixChunk(player, audiobuffer[nextbuf], 44100/50);
120+ mixChunk(player, audiobuffer[nextbuf], 882);
108121 waveOutPrepareHeader( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) );
109122 waveOutWrite( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) );
110123 nextbuf = (nextbuf+1)%BUFFNUM;
111124
112125 // Don't do this in your own player or plugin :-)
113126 //while( waveOutUnprepareHeader( hWaveOut, &header[nextbuf], sizeof( WAVEHDR ) ) == WAVERR_STILLPLAYING ) ;
114127 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+ }
115165 WaitForSingleObject(eventh, INFINITE);
116166 }
117167 ResetEvent(eventh);
118168 }
src/syntrax/syntrax.cView
@@ -2330,8 +2330,11 @@
23302330 {
23312331 int i, j;
23322332 info->coarse = p->posCoarse;
23332333 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;
23342337 for (i = 0, j = 0; i < p->channelNumber; i++)
23352338 {
23362339 Voice *v = &p->voices[i];
23372340 if (v->waveBuff != p->silentBuffer)
src/syntrax/syntrax.hView
@@ -351,8 +351,11 @@
351351 {
352352 unsigned char coarse;
353353 unsigned char fine;
354354 unsigned char channelsPlaying;
355+ char subsongName[33];
356+ int selectedSubs;
357+ int totalSubs;
355358 } syntrax_info;
356359
357360 void playerGetInfo(Player *, syntrax_info *);
358361

Built with git-ssb-web