Exemple #1
0
int main(int argc, char* argv[])
{
	printf("--- MIDISYS ENGINE: bilotrip foundation MIDISYS ENGINE 0.1 - dosing, please wait\n");
	
	// init graphics

	InitGraphics(argc, argv);

	// load shaders

	eye_shaderProg = LoadShader("eye");
	fsquad_shaderProg = LoadShader("fsquad");
	redcircle_shaderProg = LoadShader("redcircle");

	// load textures

	grayeye_tex = LoadTexture("grayeye.png");

	room_tex[0] = LoadTexture("room1.png");
	room_tex[1] = LoadTexture("room2.png");
	room_tex[2] = LoadTexture("room3.png");

	// init MIDI sync and audio

	LoadMIDIEventList("music.mid");
	ParseMIDITimeline("mapping.txt");
	InitAudio("music.mp3");

	// start mainloop

	StartMainLoop();
	return 0;
}
HumanView::HumanView(shared_ptr<IRenderer> renderer)
{
	InitAudio();

	m_pProcessManager = CB_NEW ProcessManager;

	m_PointerRadius = 1;
	m_ViewId = CB_INVALID_GAMEVIEW_ID;

	RegisterAllDelegates();
	m_BaseGameState = BaseGameState::Initializing;

	if (renderer)
	{
		// create the scene graph and camera
		m_pScene.reset(CB_NEW ScreenElementScene(renderer));

		Frustrum frustrum;
		frustrum.Init(CB_PI / 4.0f, 1.0f, 1.0f, 100.0f);
		m_pCamera.reset(CB_NEW CameraNode(&Mat4x4::Identity, frustrum));
		CB_ASSERT(m_pScene && m_pCamera && L"Out of Memory");

		m_pScene->AddChild(INVALID_GAMEOBJECT_ID, m_pCamera);
		m_pScene->SetCamera(m_pCamera);
	}

	m_LastDraw = 0;
}
Exemple #3
0
//
// HumanView::HumanView - Chapter 10, page 272
//
HumanView::HumanView(shared_ptr<IRenderer> renderer)
{
	InitAudio(); 

	m_pProcessManager = GCC_NEW ProcessManager;

	m_PointerRadius = 1;	// we assume we are on a mouse enabled machine - if this were a tablet we should detect it here.
	m_ViewId = gc_InvalidGameViewId;

	// Added post press for move, new, and destroy actor events and others
	RegisterAllDelegates();
	m_BaseGameState = BGS_Initializing;		// what is the current game state

	if (renderer)
	{
		// Moved to the HumanView class post press
		m_pScene.reset(GCC_NEW ScreenElementScene(renderer));

		Frustum frustum;
		frustum.Init(GCC_PI/4.0f, 1.0f, 1.0f, 100.0f);
		m_pCamera.reset(GCC_NEW CameraNode(&Mat4x4::g_Identity, frustum));
		GCC_ASSERT(m_pScene && m_pCamera && _T("Out of memory"));

		m_pScene->VAddChild(INVALID_ACTOR_ID, m_pCamera);
		m_pScene->SetCamera(m_pCamera);
	}
}
Exemple #4
0
void Application::Init()
{
	double T1 = glfwGetTime();

	ParseArgs();

#ifdef WIN32
	SetConsoleOutputCP(CP_UTF8);
	_setmode(_fileno(stdout), _O_U8TEXT); 
#endif

	GameState::GetInstance().Initialize();
	GameState::Printf("Initializing... \n");

	Configuration::Initialize();
	FileManager::Initialize();

	if (RunMode == MODE_PLAY || RunMode == MODE_VSRGPREVIEW)
	{
		WindowFrame.AutoSetupWindow(this);
		InitAudio();
		Game = NULL;
	}

	GameState::Printf("Total Initialization Time: %fs\n", glfwGetTime() - T1);
}
int vmsStartRecord(VmsPlayRecordType *vmsP)
{
	int er;
		vmsP->playRecordObj = gsm_create();
		SetAudioTypeLocal(0,2);//record 
		vmsP->aqRecordPlayPcm = InitAudio(vmsP, CallBackVmsUI, CallBackVmsSoundPCM);//playback
		if(CreateSoundThread(false,vmsP->aqRecordPlayPcm,false,0))
		{
			DeInitAudio( vmsP->aqRecordPlayPcm,false);
			vmsP->aqRecordPlayPcm = 0;
			return 1;
			
		}
		else
		{	
			er = PlayAudio(vmsP->aqRecordPlayPcm);
			if(er)
			{	
				DeInitAudio( vmsP->aqRecordPlayPcm,true);
				vmsP->aqRecordPlayPcm = 0;
			
			}	
			return er;
		}	
	
	
}
void AudioCaptureThread::Start()
{
    InitAudio();

    super::Start();

    m_outThread.Start();
}
Exemple #7
0
J_PL_RESULT CXPlTransform::AudioLoopPush()
{
	J_PL_RESULT br = J_PL_NO_ERROR;
	m_aDecoder = CXPlAudioDecode::CreateInstance(m_decoders.aType);
	if(!m_aDecoder)
		return J_PL_ERROR_AUDIO_DECODE;

	J_PlControl *ctl = reinterpret_cast<J_PlControl*>(m_control);
	bool bFirst = true;
	char *srcData = new char[MAX_AUDIO_FRAME_SIZE];
	char *dstData = new char[MAX_AUDIO_FRAME_SIZE];
	int srcLen = 0;
	int dstlen = 0;
	int state = J_PL_NORMAL;
	++(*ctl->m_ThreadNumer);

	while(state != J_PL_END && state != J_PL_ERROR)
	{
		ctl->m_switch.Wait();
		
		j_pl_buffer_t head;
		j_pl_decode_t format;
		j_pl_audio_format_t aout;
		
		br = ctl->m_input->m_buffer->Read(srcData,(char*)&format,head);
		if(br == J_PL_NO_ERROR)
		{
			if(format.type == DECODE_AUDIO)
			{	
				br = m_aDecoder->Decode(srcData,format.size,dstData,&dstlen);
				if(bFirst)
				{
					InitAudio();
					bFirst = false;
				}
				aout.size		= dstlen;
				aout.timestamp	= format.timestamp;
				head.datasize	= dstlen;
				head.extrasize	= sizeof(j_pl_audio_format_t);
				head.datatype	= 2;
				m_abuffer->Write(dstData,(char*)&aout,head);
				ctl->m_input->m_buffer->MoveNext();
			}
			else
				Sleep(1);
		}
		else
		{
			ctl->m_input->m_buffer->WaitData();
		}
		ctl->m_state->GetVariable(&state);
	}
	delete srcData;
	delete dstData;
	
	return br;
}
Exemple #8
0
int main(int argc, char* argv[])
{
    SetSphereDirectory();

    // load the configuration settings, then save it for future reference
    SPHERECONFIG config;
    LoadSphereConfiguration(&config);

    for (int i = 0; i < 4; i++)
    {
        SetPlayerConfig(i,
                KeyStringToKeyCode(config.player_configurations[i].key_menu_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_up_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_down_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_left_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_right_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_a_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_b_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_x_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_y_str.c_str()),
                config.player_configurations[i].keyboard_input_allowed,
                config.player_configurations[i].joypad_input_allowed);
    }

	SetGlobalConfig(config.language, config.sound, config.allow_networking);
    SaveSphereConfig(&config, (GetSphereDirectory() + "/engine.ini").c_str());

    // initialize screenshot directory
    std::string sphere_directory;
    char screenshot_directory[512];
    GetDirectory(sphere_directory);
    sprintf(screenshot_directory, "%s/screenshots", sphere_directory.c_str());
    SetScreenshotDirectory(screenshot_directory);

    // initialize video subsystem
    if (InitVideo(&config) == false)
    {
        printf("Video subsystem could not be initialized...\n");
        return 0;
    }

    // initialize input
    InitInput();

    // initialize audio
    if (!InitAudio(&config))
    {
        printf("Sound could not be initialized...\n");
    }

    atexit(CloseVideo);
    atexit(CloseAudio);

    RunSphere(argc, const_cast<const char **>(argv));

    return 0;
}
bool COSSAudioSource::Init(void)
{
  bool rc = InitAudio(true);

  if (!rc) {
    return false;
  }

  if (!InitDevice()) {
    return false;
  }
  rc = SetAudioSrc(
                   PCMAUDIOFRAME,
                   m_channelsConfigured,
                   m_pConfig->GetIntegerValue(CONFIG_AUDIO_SAMPLE_RATE));

  if (!rc) {
    return false;
  }

  // for live capture we can match the source to the destination
  m_audioSrcSamplesPerFrame = m_audioDstSamplesPerFrame;
  m_pcmFrameSize = 
    m_audioSrcSamplesPerFrame * m_audioSrcChannels * sizeof(u_int16_t);

  if (m_audioOssMaxBufferSize > 0) {
    size_t array_size;
    m_audioOssMaxBufferFrames = m_audioOssMaxBufferSize / m_pcmFrameSize;
    if (m_audioOssMaxBufferFrames == 0) {
      m_audioOssMaxBufferFrames = 1;
    }
    array_size = m_audioOssMaxBufferFrames * sizeof(*m_timestampOverflowArray);
    m_timestampOverflowArray = (Timestamp *)Malloc(array_size);
    memset(m_timestampOverflowArray, 0, array_size);
  }
    
  m_pcmFrameBuffer = (u_int8_t*)malloc(m_pcmFrameSize);
  if (!m_pcmFrameBuffer) {
    goto init_failure;
  }

  // maximum number of passes in ProcessAudio, approx 1 sec.
  m_maxPasses = m_audioSrcSampleRate / m_audioSrcSamplesPerFrame;

  return true;

 init_failure:
  debug_message("audio initialization failed");

  free(m_pcmFrameBuffer);
  m_pcmFrameBuffer = NULL;

  close(m_audioDevice);
  m_audioDevice = -1;
  return false;
}
Exemple #10
0
// Инициализация библиотеки эмулятора
void InitEGraph()
{
char pcCaption[80];
if (strlen(szVideoDriver)!=0)
  {
  strcpy(pcCaption, "SDL_VIDEODRIVER=");
  strcat(pcCaption,szVideoDriver);
  putenv(pcCaption);
  }
if (strlen(szAudioDriver)!=0)
  {
  strcpy(pcCaption, "SDL_AUDIODRIVER=");
  strcat(pcCaption,szAudioDriver);
  putenv(pcCaption);
  }
//putenv("SDL_VIDEODRIVER=windib");
//putenv("SDL_AUDIODRIVER=waveout");
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
if (!bMute)
  bMute=SDL_InitSubSystem(SDL_INIT_AUDIO);

char pcDrvName[20];
strcpy(pcCaption, "Emu80/SDL v. 3.14 development (video: ");
SDL_VideoDriverName(pcDrvName, 20);
strcat(pcCaption,pcDrvName);
if (!bMute)
  {
  strcat(pcCaption,", audio: ");
  SDL_AudioDriverName(pcDrvName, 20);
  strcat(pcCaption,pcDrvName);
  }
strcat(pcCaption,"), F10 - menu");

//SDL_WM_SetCaption("Emu80 / SDL", 0);
SDL_WM_SetCaption(pcCaption, 0);

atexit(SDL_Quit);

//semDraw=SDL_CreateSemaphore(1);

/*sfScreen = SDL_SetVideoMode(640, 480, 8,
                            SDL_HWSURFACE |
                            SDL_HWPALETTE);*/
pcScreenBuf=new char[160*64];
ClearScreen();
LoadFonts();

SetVideoMode(vmText30);
//ChangeResolution();

//SDL_ShowCursor(SDL_DISABLE);
ClearScreen();

InitAudio();
}
Exemple #11
0
//called when plugin is used by emu (you should do first time init here)
s32 FASTCALL Init(aica_init_params* initp)
{
	memcpy(&aica_params,initp,sizeof(aica_params));

	init_mem();
	AICA_Init();
	InitAudio();

	eminf.SetMenuItemStyle(config_scmi,MIS_Grayed,MIS_Grayed);
	return rv_ok;
}
Exemple #12
0
static bool tcInit(void)
{
    SDL_Init(0);

    if (setup.Debug >= ERR_DEBUG) {
        pcErrOpen(ERR_OUTPUT_TO_DISK, "debug.txt");
    } else {
        pcErrOpen(ERR_NO_OUTPUT, NULL);
    }

    InitAudio();

    StdBuffer1 = TCAllocMem(STD_BUFFER1_SIZE, true);
    StdBuffer0 = TCAllocMem(STD_BUFFER0_SIZE, true);

    if (!StdBuffer0 || !StdBuffer1) {
        return false;
    }

    if (setup.CDAudio) {
        if ((CDRomInstalled = CDROM_Install())) {
            CDROM_WaitForMedia();
            return false;
        }
    }

    gfxInit();
    SDL_WM_SetCaption("Der Clou!", NULL);

    sndInit();

    if (!(GamePlayMode & GP_NO_SAMPLES))
        sndInitFX();

    ShowIntro();

    /* Start game. */
    inpOpenAllInputDevs();

    txtInit(AutoDetectLanguage());

    AutoDetectVersion();

    InitAnimHandler();

    dbInit();
    plInit();

    gfxCollToMem(128, &StdRP0InMem);    /* cache Menu in StdRP0InMem */
    gfxCollToMem(129, &StdRP1InMem);    /* cache Bubbles in StdRP1InMem */

    CurrentBackground = BGD_LONDON;
    return true;
}
Exemple #13
0
	void Init() {
	    if(Type == EFF_AUDIO_STREAM)
		InitAudio();
	    else if(Type == EFF_VIDEO_STREAM)
		InitVideo();
	    Frame = av_frame_alloc();
	    if(Frame == NULL)
		throw TFFmpegException("Couldn't allocate frame");
	    FrameSize = 0;
	    FrameOffs = 0;
	}
Exemple #14
0
 BLOCO_API HumanView::HumanView()
{
	InitAudio(); 

	m_pProcessManager = DEBUG_CLIENTBLOCK CProcessManager();
	m_pFont = NULL;
	m_pFontFactory = NULL;
	m_pRenderer = NULL;
	
	m_pConsole = DEBUG_CLIENTBLOCK Console();
}
	bool OverWorldState::Enter()
	{
		m_player_status_manager = ServiceLocator<PlayerStatusManager>::GetService();
		m_OVPlayer = new OVPlayer();
		m_OVArea = new OVArea(m_player_status_manager->GetAreaName()+".txt",this,m_OVPlayer);
		m_draw_manager = ServiceLocator<DrawManager>::GetService();
		m_input_manager = ServiceLocator<InputManager>::GetService();
		InitAudio();
		m_mouse = m_input_manager->GetMouse();
		m_exitState = false;
		return true;
	}
bool CALSAAudioSource::Init(void)
{
  bool rc = InitAudio(true);

  if (!rc) {
    return false;
  }

  if (!InitDevice()) {
    return false;
  }

  //#error we will have to remove this below - the sample rate will be
  rc = SetAudioSrc(
                   PCMAUDIOFRAME,
                   m_channelsConfigured,
                   m_pConfig->GetIntegerValue(CONFIG_AUDIO_SAMPLE_RATE));

  if (!rc) {
    return false;
  }

  // for live capture we can match the source to the destination
  //  m_audioSrcSamplesPerFrame = m_audioDstSamplesPerFrame;
  // gets set 
  m_pcmFrameSize = m_audioSrcSamplesPerFrame * m_audioSrcChannels * sizeof(u_int16_t);

  if (m_audioMaxBufferSize > 0) {
    size_t array_size;
    m_audioMaxBufferFrames = m_audioMaxBufferSize / m_pcmFrameSize;
    if (m_audioMaxBufferFrames == 0) {
      m_audioMaxBufferFrames = 1;
    }
    array_size = m_audioMaxBufferFrames * sizeof(*m_timestampOverflowArray);
    m_timestampOverflowArray = (Timestamp *)Malloc(array_size);
    memset(m_timestampOverflowArray, 0, array_size);
  }
    
  // maximum number of passes in ProcessAudio, approx 1 sec.
  m_maxPasses = m_audioSrcSampleRate / m_audioSrcSamplesPerFrame;

  return true;

#if 0
 init_failure:
  debug_message("audio initialization failed");

  snd_pcm_close(m_pcmHandle);
  m_pcmHandle = -1;
  return false;
#endif
}
Exemple #17
0
int openSoundInterface(void *udata,int isFullDuplex)
{
	LtpInterfaceType *ltpInterfaceP;
	ltpInterfaceP = (LtpInterfaceType *)udata;
	if(ltpInterfaceP->ltpObjectP->sipOnB || ltpInterfaceP->playbackP ||ltpInterfaceP->stopAutioQueueImidateB==true)
	{
		return 0;
	}
	ltpInterfaceP->holdB = false;
	DeInitAudio( ltpInterfaceP->playbackP,false);
	DeInitAudio( ltpInterfaceP->recordP,false);
	ltpInterfaceP->playbackP = 0;
	ltpInterfaceP->recordP = 0;
	SetAudioTypeLocal(ltpInterfaceP,0);//record as well as play back
	ltpInterfaceP->playbackP = InitAudio(ltpInterfaceP, CallBackUI, 0);//playback
	if(CreateSoundThread(true,ltpInterfaceP->playbackP,false,0))
	{
		DeInitAudio( ltpInterfaceP->playbackP,false);
		ltpInterfaceP->playbackP = 0;

	}
	
	ltpInterfaceP->recordP = InitAudio(ltpInterfaceP, CallBackUI, CallBackSoundPCM);
	
	if(CreateSoundThread(false,ltpInterfaceP->recordP,false,ltpInterfaceP->ltpObjectP->soundBlockSize*2))
	{
		  DeInitAudio( ltpInterfaceP->recordP,false);
		  ltpInterfaceP->recordP = 0;
			  
		  
	}  
	PlayAudio(ltpInterfaceP->recordP);
	//sleep(10);
	PlayAudio(ltpInterfaceP->playbackP);
	//PlayAudio(ltpInterfaceObjectP->recordP);
	
	return 0;
}
Exemple #18
0
void Initialise(int argc, char *argv[])
{
   InitThreads(HT_MSGMON);
	if(InitShell(argc,argv,hnettest_version)<SUCCESS)
		HError(999,"Initialise: couldnt init HShell");
	InitMem();   InitLabel();
	InitMath();  InitSigP();
	InitWave();  InitAudio();
	if(InitParm()<SUCCESS)
		HError(999,"Initialise: couldnt init HParm");
	InitGraf(FALSE);  InitModel();
	InitDict();  InitNet();
	EnableBTrees();   /* allows unseen triphones to be synthesised */
	if (!InfoPrinted() && NumArgs() == 0)
		ReportUsage();
}
Exemple #19
0
int main(int argc, char *argv[])
{
	int n,a1,a2,a3,a4;

	InitThreads(sMon);
	if(InitShell(argc,argv,hthreadtest_version)<SUCCESS)
		HError(1100,"HThreadTest: InitShell failed");
	if (NumArgs() < 1) ReportUsage();
	InitMem();   InitLabel();
	InitMath();  InitSigP();
	InitWave();  InitAudio();
	InitVQ();
	if(InitParm()<SUCCESS)
		HError(3200,"HThreadTest: InitParm failed");
	InitGraf(FALSE);
   if (sMon==HT_MSGMON) HCreateMonitor(tmon4,(void *)0);
	if (NextArg() == INTARG){
		n = GetIntArg();
		switch(n){
		case 1:
			a1 = GetIntArg(); a2 = GetIntArg();
			ParallelForkAndJoin(a1,a2); break;
		case 2:
			a1 = GetIntArg(); a2 = GetIntArg();
			SimpleMutex(a1,a2); break;
		case 3:
			SimpleSignal(); break;
		case 4:
			a1 = GetIntArg(); a2 = GetIntArg();
			a3 = GetIntArg(); a4 = GetIntArg();
			BufferTest(a1,a2,a3,a4,GetStrArg()); break;
		default:
			printf("Bad test number %d\n",n); ReportUsage();
		}
	}
	if (sMon>0){
		AccessStatus();
		PrintThreadStatus("Final");
		ReleaseStatusAccess();
		if (sMon==HT_MSGMON)HJoinMonitor();
	}
}
Exemple #20
0
TbBool init_sound(void)
{
    struct SoundSettings *snd_settng;
    unsigned long i;
    SYNCDBG(8,"Starting");
    if (SoundDisabled)
      return false;
    snd_settng = &game.sound_settings;
    SetupAudioOptionDefaults(snd_settng);
    snd_settng->field_E = 3;
    snd_settng->sound_type = 1622;
    snd_settng->sound_data_path = sound_dir;
    snd_settng->dir3 = sound_dir;
    snd_settng->field_12 = 1;
    snd_settng->stereo = 1;
    i = get_best_sound_heap_size(mem_size);
    if (i < 1048576)
      snd_settng->max_number_of_samples = 10;
    else
      snd_settng->max_number_of_samples = 16;
    snd_settng->danger_music = 0;
    snd_settng->no_load_music = 0;
    snd_settng->no_load_sounds = 1;
    snd_settng->field_16 = 1;
    if ((game.flags_font & FFlg_UsrSndFont) == 0)
      snd_settng->field_16 = 0;
    snd_settng->field_18 = 1;
    snd_settng->redbook_enable = ((game.flags_cd & MFlg_NoCdMusic) == 0);
    snd_settng->sound_system = 0;
    InitAudio(snd_settng);
    LoadMusic(0);
    InitializeMusicPlayer();
    if (!GetSoundInstalled())
    {
      SoundDisabled = 1;
      return false;
    }
    S3DInit();
    S3DSetNumberOfSounds(snd_settng->max_number_of_samples);
    S3DSetMaximumSoundDistance(5120);
    return true;
}
Exemple #21
0
/* constructor and destructor */
CSDL_ApplicationBase::CSDL_ApplicationBase(long flags) {
    m_bIsRunning = true;
    m_pErrorBuffer = new char[256];
    m_bIsOpenGL = (flags & SDL_OPENGL) ? true : false;
    m_bIsFullscreen = false;
    m_PrimarySurface = NULL;
    ::atexit (::SDL_Quit);
    if(flags & SDL_INIT_VIDEO) {
        InitVideo();
    }

    if(flags & SDL_INIT_AUDIO) {
        InitAudio();
    }
    if(flags & SDL_OPENGL) {
//        InitOpenGL();
        SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
        SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ) ;
    }


    Uint32          colorkey;
    SDL_Surface     *image;
    image = SDL_LoadBMP("data/Orc.bmp");
    colorkey = SDL_MapRGB(image->format, 255, 0, 255);
    SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
    SDL_WM_SetIcon(image,NULL);

    SetCaption("Loading...");

    SetVideoMode(800, 600, 32, ((m_bIsFullscreen) ? SDL_FULLSCREEN : 0) | ((m_bIsOpenGL) ? SDL_OPENGL : SDL_HWSURFACE|SDL_DOUBLEBUF));


    m_MouseCursorSurface = new CSDL_Surface("data/cursor.bmp");
//    m_MouseCursorSurface->SetColorKey(255, 0, 255, SDL_SRCCOLORKEY|SDL_RLEACCEL);

    FPS_Init();

} // constructor
Exemple #22
0
void main(void) {
#if 0 /*Perform some extra inits because we are started from SPI boot. */
    InitAudio(); /* goto 3.0x..4.0x */
    PERIP(INT_ENABLEL) = INTF_RX | INTF_TIM0;
    PERIP(INT_ENABLEH) = INTF_DAC;
    //ph = FsPhNandCreate(0); /*We do not use FLASH, so no init for it. */
#endif

    /* Set the leds after nand-boot! */
    PERIP(GPIO1_ODATA) |=  LED1|LED2;      /* POWER led on */
    PERIP(GPIO1_DDR)   |=  LED1|LED2; /* SI and SO to outputs */
    PERIP(GPIO1_MODE)  &= ~(LED1|LED2); /* SI and SO to GPIO */

    /* Initialize RC5 reception */
    Rc5Init(INTV_GPIO0);
    PERIP(GPIO0_INT_FALL) |= (1<<14); /*DISPLAY_XCS*/
    PERIP(GPIO0_INT_RISE) |= (1<<14);
    PERIP(INT_ENABLEL) |= INTF_GPIO0;

    SetHookFunction((u_int16)IdleHook, MyUserInterfaceIdleHook);
    SetHookFunction((u_int16)USBSuspend, MyUSBSuspend);
#if 0
    while (1) {
	register u_int16 t = Rc5GetFIFO();
	if (t) {
	    puthex(t);
	    puts("=got");
	}
    }
#endif
#if 0
    while (1) {
	s_int16 tmp[32];
	memset(tmp, 0, sizeof(tmp));
	AudioOutputSamples(tmp, 16);
    }
#endif
}
Exemple #23
0
void main() {
    ALport alp;
    FileDescriptor dacfd, sockfd;	
    int udp_port = 7000;
    SynthState voices[2];


    InitVoice(voices, 440);
    InitVoice(voices+1, 220);

    dacfd = InitAudio(&alp);
    sockfd = initudp(udp_port);
    if(sockfd<0) {
	perror("initudp");
	return;
    }

    InitPriority();

    InitOSC(voices, voices+1);

    MainLoop(alp, dacfd, sockfd, voices, voices+1);
}
Exemple #24
0
int PauseAudio(int Switch)
{
    static int Rate,Latency;

    // If audio not initialized, return "off"
    if(!SndRate&&!AudioPaused) return(0);

    // Toggle audio status if requested
    if(Switch==2) Switch=AudioPaused? 0:1;

    // When switching audio state...
    if((Switch>=0)&&(Switch<=1)&&(Switch!=AudioPaused))
    {
#ifdef __PLAYBOOK__
        SDL_PauseAudio(Switch);
#else
        if(Switch)
        {
            // Memorize audio parameters and kill audio
            Rate    = SndRate;
            Latency = 1000*SndSize/SndRate;
            TrashAudio();
        }
        else
        {
            // Start audio using memorized parameters
            if(!InitAudio(Rate,Latency)) Switch=0;
        }
#endif

        // Audio switched
        AudioPaused=Switch;
    }

    // Return current status
    return(AudioPaused);
}
Exemple #25
0
int emuInit(){
    emuFrameBuffer = new QImage(320, 240, QImage::Format_RGB16);
    emuAudioBuffer = new QByteArray(SOUND_BUFFER_SIZE,0);
    if( emu_psx_bias ){
        autobias=0;
        BIAS = emu_psx_bias;
    }else{
        autobias=1;
    }
    PSXCLK=(u32)((double)PSXCLK*emu_clock_multiplier);
    Config.Xa=emu_audio_xa; /* 0=XA enabled, 1=XA disabled */
    Config.Mdec=emu_video_mdec; /* 0=Black&White Mdecs Only Disabled, 1=Black&White Mdecs Only Enabled */
    Config.Cdda=emu_audio_cd; /* 0=Enable Cd audio, 1=Disable Cd audio */
    Config.HLE=emu_enable_bios; /* 0=BIOS, 1=HLE */
    Config.Cpu=emu_cpu_type; /* 0=recompiler, 1=interpreter */
    Config.PsxAuto=1; /* 1=autodetect system (pal or ntsc) */
    Config.PsxType=0; /* PSX_TYPE_NTSC=ntsc, PSX_TYPE_PAL=pal */
    Config.RCntFix=0; /* 1=Parasite Eve 2, Vandal Hearts 1/2 Fix */
    Config.VSyncWA=0; /* 1=InuYasha Sengoku Battle Fix */

    // gpu_unai
#ifdef gpu_unai
    extern int skipCount; skipCount=emu_frameskip; /* frame skip (0,1,2,3...) */
    //extern bool enableAbbeyHack; enableAbbeyHack=false; /* Abe's Odyssey hack */
    extern int linesInterlace_user; linesInterlace_user=0; /* interlace */
    extern bool skipGPU; skipGPU = emu_skip_gpu; /* skip GPU primitives */
    extern bool frameLimit; frameLimit = emu_frame_limit; /* frames to wait */
    extern bool light; light = emu_video_light; /* lighting */
    extern bool blend; blend = emu_video_blend; /* blending */
    extern bool show_fps; show_fps = 0;//emu_framerate; /* blending */
#endif
#ifdef spu_franxis
    extern bool nullspu; nullspu = !emu_sound_enable; /* lighting */
#endif
    SCREEN = (unsigned short*)emuFrameBuffer->bits();
    InitAudio();
}
Exemple #26
0
void RtsForm::InitWindow()
{
	m_pRoot->AttachBubbledEvent(ui::kEventAll, nbase::Bind(&RtsForm::Notify, this, std::placeholders::_1));
	m_pRoot->AttachBubbledEvent(ui::kEventClick, nbase::Bind(&RtsForm::OnClicked, this, std::placeholders::_1));

	chat_status_ = (Label*)FindControl(L"chat_status");
	chat_status2_ = (Label*)FindControl(L"chat_status2");
	ctrl_notify_ = (Label*)FindControl(L"ctrl_notify");
	speak_ = (CheckBox*)FindControl(L"speak");
	speak_->Selected(false);
	board_ = (BoardControl*)FindControl(L"board");
	board_->AttachAllEvents(nbase::Bind(&RtsForm::Notify, this, std::placeholders::_1));
	board_->SetDrawCb(nbase::Bind(&RtsForm::OnDrawCallback, this, std::placeholders::_1));

	ShowHeader();

	auto closure = nbase::Bind(&RtsForm::SendCurData, this);
	nbase::ThreadManager::PostRepeatedTask(kThreadUI, closure, nbase::TimeDelta::FromMilliseconds(60));

	if (type_ & nim::kNIMRtsChannelTypeVchat)
	{
		InitAudio();
	}
}
int vmsStartPlay(VmsPlayRecordType *vmsP)
{
	vmsP->playRecordObj = gsm_create();
	SetAudioTypeLocal(0,1);// play back
	SetSpeakerOnOrOff(0, 1);
	vmsP->aqRecordPlayPcm = InitAudio(vmsP, CallBackVmsUI, CallBackVmsSoundPCM);//playback
	if(CreateSoundThread(true,vmsP->aqRecordPlayPcm,false,0))
	{
		DeInitAudio( vmsP->aqRecordPlayPcm,false);
		vmsP->aqRecordPlayPcm = 0;
		return 1;
	}
	else
	{	
		//vmsP->aqRecordPlayPcm->playStartedB = true;
		PlayBuffStart(vmsP->aqRecordPlayPcm);
		PlayAudio(vmsP->aqRecordPlayPcm);
		return 0;
		
		
	}	
	
	
}
Exemple #28
0
int main(int argc, char *argv[])
{
   char *datafn, *s;
   int nSeg;
   void Initialise(void);
   void LoadFile(char *fn);
   void EstimateModel(void);
   void SaveModel(char *outfn);
   
   if(InitShell(argc,argv,hinit_version,hinit_vc_id)<SUCCESS)
      HError(2100,"HInit: InitShell failed");
   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2100,"HInit: InitParm failed");
   InitTrain(); InitUtil();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);
   SetConfParms();

   CreateHMMSet(&hset,&gstack,FALSE);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2119,"HInit: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'e':
         epsilon = GetChkedFlt(0.0,1.0,s); break;
      case 'i':
         maxIter = GetChkedInt(0,100,s); break;
      case 'l':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Segment label expected");
         segLab = GetStrArg();
         break;
      case 'm':
         minSeg = GetChkedInt(1,1000,s); break;
      case 'n':
         newModel = FALSE; break;
      case 'o':
         outfn = GetStrArg();
         break;
      case 'u':
         SetuFlags(); break;
      case 'v':
         minVar = GetChkedFlt(0.0,10.0,s); break;
      case 'w':
         mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); 
         break;
      case 'B':
         saveBinary = TRUE;
         break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Data File format expected");
         if((dff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Data file format set");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Label File format expected");
         if((lff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Label file format set");
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: HMM macro file name expected");
         AddMMF(&hset,GetStrArg());
         break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: MLF file name expected");
         LoadMasterFile(GetStrArg());
         break;
      case 'L':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file directory expected");
         labDir = GetStrArg(); break;
      case 'M':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Output macro file directory expected");
         outDir = GetStrArg();
         break;
      case 'T':
         if (NextArg() != INTARG)
            HError(2119,"HInit: Trace value expected");
         trace = GetChkedInt(0,01777,s);
         break;
      case 'X':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file extension expected");
         labExt = GetStrArg(); break;
      default:
         HError(2119,"HInit: Unknown switch %s",s);
      }
   }
   if (NextArg()!=STRINGARG)
      HError(2119,"HInit: source HMM file name expected");
   hmmfn = GetStrArg();
   Initialise();
   do {
      if (NextArg()!=STRINGARG)
         HError(2119,"HInit: training data file name expected");
      datafn = GetStrArg();
      LoadFile(datafn);
   } while (NumArgs()>0);
   nSeg = NumSegs(segStore);
   if (nSeg < minSeg)
      HError(2121,"HInit: Too Few Observation Sequences [%d]",nSeg);
   if (trace&T_TOP) {
      printf("%d Observation Sequences Loaded\n",nSeg);
      fflush(stdout);
   }
   EstimateModel();
   SaveModel(outfn);
   if (trace&T_TOP)
      printf("Output written to directory %s\n",
             outDir==NULL?"current":outDir);
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}
Exemple #29
0
int main_HCopy(int argc, char *argv[])
{
   char *s;                     /* next file to process */
   void OpenSpeechFile(char *s);
   void AppendSpeechFile(char *s);
   void PutTargetFile(char *s);

   if(InitShell(argc,argv,hcopy_version,hcopy_vc_id)<SUCCESS)
      HError(1000,"HCopy: InitShell failed");
   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(1000,"HCopy: InitParm failed");

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsageHCopy();
   if (NumArgs() == 0) return(0);

   SetConfParmsHCopy();
   /* initial trace string is null */
   trList.str = NULL;

   CreateHeap(&iStack, "InBuf",   MSTAK, 1, 0.0, STACKSIZE, LONG_MAX);
   CreateHeap(&oStack, "OutBuf",  MSTAK, 1, 0.0, STACKSIZE, LONG_MAX);
   CreateHeap(&cStack, "ChopBuf", MSTAK, 1, 0.0, STACKSIZE, LONG_MAX);
   CreateHeap(&lStack, "LabBuf",  MSTAK, 1, 0.0, 10000, LONG_MAX);
   CreateHeap(&tStack, "Trace",   MSTAK, 1, 0.0, 100, 200);

   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(1019,"HCopy: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'a':
         if (NextArg() != INTARG)
            HError(1019,"HCopy: Auxiliary label index expected");
         auxLab = GetChkedInt(1,100000,s) - 1;
         break;
      case 'e':              /* end time in seconds, max 10e5 secs */
         en = GetChkedFlt(-MAXTIME,MAXTIME,s);
         stenSet = TRUE; chopF = TRUE;
         break;
      case 'i':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: Output MLF name expected");
         if(SaveToMasterfile(GetStrArg())<SUCCESS)
            HError(1014,"HCopy: Cannot write to MLF");
         useMLF = TRUE; labF = TRUE; break;
      case 'l':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: Target label file directory expected");
         outLabDir = GetStrArg();
         labF = TRUE; break;
      case 'm':
         xMargin = GetChkedFlt(-MAXTIME,MAXTIME,s);
         chopF = TRUE; break;
      case 'n':
         if (NextArg() != INTARG)
            HError(1019,"HCopy: Label index expected");
         labstidx= GetChkedInt(-100000,100000,s);
         if (NextArg() == INTARG)
            labenidx = GetChkedInt(-100000,100000,s);
         chopF = TRUE; break;          
      case 's':      /* start time in seconds */
         st = GetChkedFlt(0,MAXTIME,s);
         stenSet = TRUE; chopF = TRUE; break;
      case 't':
         if (NextArg() != INTARG)
            HError(1019,"HCopy: Trace line width expected");
         traceWidth= GetChkedInt(10,100000,s); break;
      case 'x':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: Label name expected");
         labName = GetLabId(GetStrArg(),TRUE);
         if (NextArg() == INTARG)
            labRep = GetChkedInt(1,100000,s);
         chopF = TRUE; labF = TRUE; break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: Source file format expected");
         if((srcFF = Str2Format(GetStrArg())) == ALIEN)
            HError(-1089,"HCopy: Warning ALIEN src file format set");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: Source label File format expected");
         if((srcLabFF = Str2Format(GetStrArg())) == ALIEN)
            HError(-1089,"HCopy: Warning ALIEN Label output file format set");
         labF= TRUE; break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: MLF file name expected");
         LoadMasterFile(GetStrArg());
         labF = TRUE; break;
      case 'L':
         if (NextArg()!=STRINGARG)
            HError(1019,"HCopy: Label file directory expected");
         labDir = GetStrArg();
         labF = TRUE; break;
      case 'P':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: Label File format expected");
         if((tgtLabFF = Str2Format(GetStrArg())) == ALIEN)
            HError(-1089,"HCopy: Warning ALIEN Label file format set");
         labF = TRUE; break;
      case 'O':
         if (NextArg() != STRINGARG)
            HError(1019,"HCopy: Target file format expected");
         if((tgtFF = Str2Format(GetStrArg())) == ALIEN)
            HError(-1089,"HCopy: Warning ALIEN target file format set");
         break;
      case 'T':
         trace = GetChkedInt(0,16,s); break;
      case 'X':
         if (NextArg()!=STRINGARG)
            HError(1019,"HCopy: Label file extension expected");
         labExt = GetStrArg();
         labF = TRUE; break;     
      default:
         HError(1019,"HCopy: Unknown switch %s",s);
      }
   }
   if (NumArgs() == 1)  
      HError(1019,"HCopy: Target file or + operator expected");
   FixOptions();
   while (NumArgs()>1) { /* process group S1 + S2 + ... TGT */
      off = 0.0;
      if (NextArg()!=STRINGARG)
         HError(1019,"HCopy: Source file name expected");    
      s = GetStrArg();     
      OpenSpeechFile(s);               /* Load initial file  S1 */
      if (NextArg()!=STRINGARG)
         HError(1019,"HCopy: Target file or + operator expected");
      s = GetStrArg();
      while (strcmp(s,"+") == 0) {     /* Append + S2 + S3 ... */
         if (NextArg()!=STRINGARG)
            HError(1019,"HCopy: Append file name expected");
         s = GetStrArg();
         AppendSpeechFile(s);
         if (NextArg()!=STRINGARG)
            HError(1019,"HCopy: Target file or + operator expected");
         s = GetStrArg();
      }     
      PutTargetFile(s);
      if(trace & T_MEM) PrintAllHeapStats();
      if(trans != NULL){
         trans = NULL;
         ResetHeap(&lStack);
      }
      ResetHeap(&iStack);
      ResetHeap(&oStack);
      if(chopF) ResetHeap(&cStack);
   }
   if(useMLF) CloseMLFSaveFile();
   if (NumArgs() != 0) HError(-1019,"HCopy: Unused args ignored");
   return (0);          /* never reached -- make compiler happy */
}
Exemple #30
0
static Boolean tgtHdr  = FALSE;  /* print target header info */

static Boolean obsFmt  = FALSE;  /* print observation format */

static Boolean prData  = TRUE;   /* print data */

static Boolean rawOut = FALSE;   /* raw output i.e no numbering */

static Boolean replay = FALSE;   /* replay audio */

static Boolean frcDisc = FALSE;  /* List VQ symbols from cont file */

static FileFormat ff = UNDEFF;   /* Source File format */

static long gst = -1;             /* start sample to list */

static long gen = -1;             /* end sample to list */

static int numS = 1;             /* number of streams */

static int nItems  = 10;         /* num items per line */

static int barwidth;             /* width of printed bars */

static char barc = '-';          /* bar character */



/* ---------------- Configuration Parameters --------------------- */



static ConfParam *cParm[MAXGLOBS];

static int nParm = 0;            /* total num params */

static HTime sampPeriod;         /* raw audio input only */

static int audSignal;



/* ---------------- Process Command Line ------------------------- */



/* SetConfParms: set conf parms relevant to this tool */

void SetConfParms(void)

{

   int i;

   double d;



   sampPeriod = 0.0; audSignal = NULLSIG;

   nParm = GetConfig("HLIST", TRUE, cParm, MAXGLOBS);

   if (nParm>0){

      if (GetConfInt(cParm,nParm,"AUDIOSIG",&i)) audSignal = i;

      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;

      if (GetConfFlt(cParm,nParm,"SOURCERATE",&d)) sampPeriod = d;

   }

}