void shut( void ) { freesounds(); if( audioavailable ) Mix_CloseAudio(); if( joy ) SDL_JoystickClose( joy ); #ifdef HAVE_GLES eglMakeCurrent( eglDisplay, NULL, NULL, EGL_NO_CONTEXT ); if (eglContext) eglDestroyContext(eglDisplay, eglContext); if (eglSurface) eglDestroySurface(eglDisplay, eglSurface); if (eglDisplay) eglTerminate(eglDisplay); eglContext = NULL; eglSurface = NULL; eglDisplay = NULL; #endif if( needquit ) SDL_Quit(); }
//============================================================================== // MAIN //============================================================================== int main(int argc,char **argv) { pthread_t test; printf("SFemtoZ!\n"); int c; while ((c = getopt (argc, argv, "t:v")) != -1) switch (c) { case 't': if(pthread_create(&test,NULL,thread_test,optarg)) { printf("error thread test\n"); } break; case 'v': verbose=TRUE; break; } char sfzfile[50]; strcpy(sfzfile,USBPATH); strcat(sfzfile,argv[optind]); printf("Load SFZ: %s\n",sfzfile); loadsfz(sfzfile); //printsfz(); loadsounds(); int fd; if(( fd = serialOpen("/dev/ttyAMA0",57600))<0) { printf("serialOpen ERROR:\n",strerror(errno)); return 1; } if(configuresoundio()!=0) return 1; signal(SIGINT,exit_cli); signal(SIGTERM,exit_cli); run = TRUE; while(run) { if(serialDataAvail(fd)>2) { int type=serialGetchar(fd); while(type!=0x99 && type!= 0xB9) type=serialGetchar(fd); int note=serialGetchar(fd); int vel=serialGetchar(fd); //printf("MIDI%i(%i,%i)\n",type,note,vel); if(type==0x99) noteOn(note,vel); else midiCC(note,vel); } // soundio_wait_events(soundio); } //FINISH pthread_cancel(test); soundio_outstream_destroy(outstream); soundio_device_unref(device); soundio_destroy(soundio); serialClose(fd); freesounds(); freesfz(); return 0; }