// mfcsoundtest.cpp : Legt das Klassenverhalten für die Anwendung fest. // #include "stdafx.h" #include "mfcsoundtest.h" #include "MainFrm.h" #include "mfcsoundtestDoc.h" #include "mfcsoundtestView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif HANDLE enginethreadhandle = 0; DWORD engineThreadId = 0; #include /************************************************************************/ /* Animation Thread, uses the framewindow as display */ /************************************************************************/ DWORD WINAPI EngineThreadFunction1(LPVOID lpParameter) { int xpos =0; int ypos =0; llgfx_SetDisplayMode(640,480,32,0,0); llgfx_tab_chars[0] = '.'; llgfx_tab_pos[0] = 32; llgfx_id background = llgfx_LoadGfx("background.png"); llsound_id musik = llsound_LoadSnd("theme3.ogg",LLSOUND_STREAM); llsound_Play(musik,LLSOUND_LOOP); llsound_id heli = llsound_LoadSnd("helicopter_1.wav"); llsound_id vol = llsound_LoadSnd("volume.wav"); llsound_id down = llsound_LoadSnd("down.wav"); llsound_id down_array[4]; down_array[0] = llsound_CloneSnd(down); down_array[1] = llsound_CloneSnd(down); down_array[2] = llsound_CloneSnd(down); down_array[3] = llsound_CloneSnd(down); int down_index=0; llirq_ResetTime(); while(osmain_endgame==false){ float delta = llirq_GetDeltaTime(); if(background) llgfx_TILE_BLIT(0,background,xpos++,ypos++); else llgfx_ClearScreen(BLUE); llgfx_Printf("Sounddriver demo\n"); llgfx_Printf("Musik Pos:\t%f sec\n", llsound_GetSndPlaytime(musik) ); llgfx_Printf("Heli Pos:\t%f sec\n", llsound_GetSndPlaytime(heli) ); llgfx_Printf("Vol Pos:\t%f sec\n", llsound_GetSndPlaytime(vol) ); llgfx_Printf("\n"); int status = llsound_GetStatus(heli); if( status == 0 ) llgfx_Printf("Heli=Stopped, press Key_A to play\n", llsound_GetSndPlaytime(heli)); else llgfx_Printf("Heli=Resuming Playback, release Key_A to stop\n", llsound_GetSndPlaytime(heli)); if( Justdown(llinput_Keys[LLINPUT_KEY_A]) ){ llsound_Resume(heli,LLSOUND_LOOP,llsound_GetSndPlaytime(heli)); } if( Justup(llinput_Keys[LLINPUT_KEY_A]) ){ llsound_Stop(heli); } // volume.wav llgfx_Printf("\n"); if( Justdown(llinput_Keys[LLINPUT_KEY_B]) ){ llsound_Play(vol); } status = llsound_GetStatus(vol); if( status == 0 ) llgfx_Printf("vol=Stopped, press Key_B to play\n", llsound_GetSndPlaytime(vol)); else llgfx_Printf("vol=Playing\n", llsound_GetSndPlaytime(vol)); // down.wav llgfx_Printf("\n"); if( Justdown(llinput_Keys[LLINPUT_KEY_X]) ){ llsound_Play( down_array[(down_index++)%4] ); } int cnt = 4; llgfx_Printf("Press Key_X to play one of down.wav\n"); while(cnt--) { llgfx_Printf("down[%d]\t%f\n",cnt,llsound_GetSndPlaytime(down_array[cnt])); } llgfx_Printf("\n"); llgfx_Printf("Musik sndlength\t%f secs\n",llsound_GetSndLength(musik)); llgfx_Printf("Heli sndlength\t%f secs\n",llsound_GetSndLength(heli)); llgfx_Printf("vol sndlength\t%f secs\n",llsound_GetSndLength(vol)); llgfx_Printf("Down sndlength\t%f secs\n",llsound_GetSndLength(down)); llgfx_sBLITFX blitfx; blitfx.fixalpha = 0.5f; llgfx_DrawText(" l3lib v1.0 - August 2006, GP2X Win32 Driver",BLIT_FXBLEND|BLIT_SRC_CKEY,&blitfx); llgfx_FlipScreen(0); llsound_Update(delta); llinput_Update(); llirq_Sleep(10); } return 0; } DWORD WINAPI EngineThreadFunction(LPVOID lpParameter) { int xpos =0; int ypos =0; llgfx_SetDisplayMode(320,240,32,0,0); llgfx_tab_chars[0] = '.'; llgfx_tab_pos[0] = 32; llgfx_id background = llgfx_LoadGfx("background.png"); llgfx_id logo = llgfx_LoadGfx("one03.png"); llirq_ResetTime(); while(osmain_endgame==false){ float delta = llirq_GetDeltaTime(); llgfx_TILE_BLIT(0,background,xpos++,ypos++); llgfx_BLIT(0,logo,0,0,0,BLIT_DST_CENTERED); llgfx_Printf("Blitter Demo 1\nPress Key A to quit"); if( Justdown(llinput_Keys[LLINPUT_KEY_A]) ){ osmain_endgame = true; } llgfx_FlipScreen(0); llsound_Update(delta); llinput_Update(); llirq_Sleep(10); } return 0; } /************************************************************************/ /* LowLevellib start, you need a valid MainFrameWindow */ /************************************************************************/ void StartEngine(HWND mainframewindow) { llgfx_Init(mainframewindow); llsound_Init(mainframewindow); llinput_Init(mainframewindow); enginethreadhandle = (HANDLE) CreateThread( 0, 0, &EngineThreadFunction, 0, 0, &engineThreadId ); } ///////////////////////////////////////////////////////////////////////////// // CMfcsoundtestApp BEGIN_MESSAGE_MAP(CMfcsoundtestApp, CWinApp) //{{AFX_MSG_MAP(CMfcsoundtestApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) // HINWEIS - Hier werden Mapping-Makros vom Klassen-Assistenten eingefügt und entfernt. // Innerhalb dieser generierten Quelltextabschnitte NICHTS VERÄNDERN! //}}AFX_MSG_MAP // Dateibasierte Standard-Dokumentbefehle ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMfcsoundtestApp Konstruktion CMfcsoundtestApp::CMfcsoundtestApp() { // ZU ERLEDIGEN: Hier Code zur Konstruktion einfügen // Alle wichtigen Initialisierungen in InitInstance platzieren } ///////////////////////////////////////////////////////////////////////////// // Das einzige CMfcsoundtestApp-Objekt CMfcsoundtestApp theApp; ///////////////////////////////////////////////////////////////////////////// // CMfcsoundtestApp Initialisierung BOOL CMfcsoundtestApp::InitInstance() { // Standardinitialisierung // Wenn Sie diese Funktionen nicht nutzen und die Größe Ihrer fertigen // ausführbaren Datei reduzieren wollen, sollten Sie die nachfolgenden // spezifischen Initialisierungsroutinen, die Sie nicht benötigen, entfernen. #ifdef _AFXDLL Enable3dControls(); // Diese Funktion bei Verwendung von MFC in gemeinsam genutzten DLLs aufrufen #else Enable3dControlsStatic(); // Diese Funktion bei statischen MFC-Anbindungen aufrufen #endif // Ändern des Registrierungsschlüssels, unter dem unsere Einstellungen gespeichert sind. // ZU ERLEDIGEN: Sie sollten dieser Zeichenfolge einen geeigneten Inhalt geben // wie z.B. den Namen Ihrer Firma oder Organisation. SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Standard INI-Dateioptionen laden (einschließlich MRU) // Dokumentvorlagen der Anwendung registrieren. Dokumentvorlagen // dienen als Verbindung zwischen Dokumenten, Rahmenfenstern und Ansichten. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMfcsoundtestDoc), RUNTIME_CLASS(CMainFrame), // Haupt-SDI-Rahmenfenster RUNTIME_CLASS(CMfcsoundtestView)); AddDocTemplate(pDocTemplate); // Befehlszeile parsen, um zu prüfen auf Standard-Umgebungsbefehle DDE, Datei offen CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Verteilung der in der Befehlszeile angegebenen Befehle if (!ProcessShellCommand(cmdInfo)) return FALSE; // Das einzige Fenster ist initialisiert und kann jetzt angezeigt und aktualisiert werden. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); StartEngine(m_pMainWnd->m_hWnd); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CAboutDlg-Dialog für Info über Anwendung class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialogdaten //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // Überladungen für virtuelle Funktionen, die vom Anwendungs-Assistenten erzeugt wurden //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV-Unterstützung //}}AFX_VIRTUAL // Implementierung protected: //{{AFX_MSG(CAboutDlg) // Keine Nachrichten-Handler //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // Keine Nachrichten-Handler //}}AFX_MSG_MAP END_MESSAGE_MAP() // Anwendungsbefehl zum Ausführen des Dialogfelds void CMfcsoundtestApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // CMfcsoundtestApp-Nachrichtenbehandlungsroutinen