Esempio n. 1
0
void initsound()
{
	gameflags.soundsystemworks=false;

	if (commandline.sound==SOUNDOFF)
		return;

	if (SDL_InitSubSystem(SDL_INIT_AUDIO))
	{
		fprintf(stderr, "Can't start sound subsystem: %s.\nContinuing without it.\n", SDL_GetError());
	}
	else if (Mix_OpenAudio(22050, AUDIO_U8, 2, 1024))
	{
		fprintf(stderr, "Can't open audio: %s.\nContinuing without sound support.\n", SDL_GetError());
		fprintf(stderr, "You may see some other errors from system sound libraries. Ignore them.\n");
	}
	else
	{
		gameflags.soundsystemworks=true;
		loadsounds(NULL,DATAPREFIX "/" SNDFILEOUCH,DATAPREFIX "/" SNDFILEBREAK);
	}
}
Esempio n. 2
0
//==============================================================================
//   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;
}
Esempio n. 3
0
BOOL init( void )
{
  const SDL_VideoInfo *info = NULL;
  int depth;
  int flags;

  load_options();

  if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK ) < 0 )
  {
    fprintf( stderr, "SDL says: %s\n", SDL_GetError() );
    return FALSE;
  }

  joy = SDL_JoystickOpen( 0 );
  if( joy ) SDL_JoystickEventState( SDL_ENABLE );
  
//  printf( "%p\n", joy );

  needquit = TRUE;

  depth = 32;
  if( (info = SDL_GetVideoInfo()) )
    depth = info->vfmt->BitsPerPixel;

#ifdef __amigaos4__
  printf( "Detected MiniGL v%d.%d\n",
    MiniGLBase->lib_Version,
    MiniGLBase->lib_Revision );

  if( ( MiniGLBase->lib_Version < 2 ) ||
      ( ( MiniGLBase->lib_Version == 2 ) &&
        ( MiniGLBase->lib_Revision < 1 ) ) )
  {
    //screenbodge = TRUE;
    printf( "WARNING: The video screen won't work properly on the spaceship level\n" );
    printf( "with this version on MiniGL.\n" );
  }
#endif

#ifdef HAVE_GLES
flags = 0;
#else
flags = SDL_OPENGL;
#endif

#ifndef PANDORA
  if( fullscreen )
#endif
	flags |= SDL_FULLSCREEN;

#ifdef PANDORA
  ssrf = SDL_SetVideoMode( 800, 480, depth, flags );
#else
  ssrf = SDL_SetVideoMode( WINWIDTH, WINHEIGHT, depth, flags );
#endif
	
  if( ssrf == 0 )
  {
    fprintf( stderr, "SDL says: %s\n", SDL_GetError() );
    return FALSE;
  }

  SDL_ShowCursor( SDL_DISABLE );
#ifdef HAVE_GLES
// create EGL context
// *TODO* : real egl Checking for error
#define eglCheck()	 FALSE
	eglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY);
	
	// Initialise EGL
	EGLint maj, min;
	if (!eglInitialize(eglDisplay, &maj, &min))
	{
		fprintf( stderr, "EGL Error: eglInitialize failed\n");
		return FALSE;
	}
	
	EGLint pi32ConfigAttribs[]  = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT , EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_NONE };
	EGLint pi32ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 1 , EGL_NONE };

	int num_config;
	
	EGLConfig config;
	if (!eglChooseConfig(eglDisplay, pi32ConfigAttribs, &config, 1, &num_config) || (num_config != 1))
	{
		fprintf(stderr, "EGL Error: eglChooseConfig failed\n");
		return FALSE;
	}
	
	eglSurface = eglCreateWindowSurface(eglDisplay, config, NULL, NULL);
	
	if (eglCheck())
	return FALSE;
	
	eglBindAPI(EGL_OPENGL_ES_API);
	if (eglCheck())
	return FALSE;
	
	eglContext = eglCreateContext(eglDisplay, config, NULL, pi32ContextAttribs);
	
	if (eglCheck())
	return FALSE;

	eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
	
	if (eglCheck())
	return FALSE;
	
	EGLint w,h;
	eglQuerySurface(eglDisplay, eglSurface, EGL_WIDTH, &w);
	eglQuerySurface(eglDisplay, eglSurface, EGL_HEIGHT, &h);
	
	// now, setup viewport to adapt to the surface
	//*TODO* adjust if surface is smaller
	int dx = (w-WINWIDTH)/2;
	int dy = (h-WINHEIGHT)/2;
	glViewport(dx, dy, WINWIDTH, WINHEIGHT);
#endif
/*
#ifdef __amigaos4__
  if( screenbodge )
  {
    struct IntuitionBase *ibase = (struct IntuitionBase *)IntuitionBase;
    win = ibase->ActiveWindow;
    if( !win )
      screenbodge = FALSE;
  }
#endif
*/
  // initialize sdl mixer, open up the audio device
  if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 )
  {
    fprintf( stderr, "SDL_Mixer says: %s\n", Mix_GetError() );
  } else {
    audioavailable = TRUE;
  }

  loadsounds();

  if( !render_init() ) return FALSE;

  titlestate = 0;
  what_are_we_doing = WAWD_TITLES;

  return TRUE;
}