2 // sample C code using sound utilities & LG sound library
3 // Pat McElhatton August 26 '96
22 static BOOL donePlaying
= FALSE
;
25 endItAll( ISndSample
*pSample
,
30 ISndSample_Release( pSample
);
34 LRESULT FAR PASCAL
WndProc (HWND hWnd
, UINT iMessage
, WPARAM wParam
,
39 case WM_COMMAND
: // process menu items
44 default: // default windows message processing
45 return DefWindowProc (hWnd
, iMessage
, wParam
, lParam
) ;
51 #define APPNAME "stream"
59 HWND hWnd
; // a handle to a message
60 MSG msg
; // a message
61 WNDCLASS wndclass
; // the window class
70 "USAGE: stream <fname1> play a file in stream mode",
71 " if fname does not have an extension, .wav extension is added.");
76 hInstance
= GetModuleHandle( NULL
);
78 // load data into window class struct.
79 wndclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
80 wndclass
.lpfnWndProc
= WndProc
;
81 wndclass
.cbClsExtra
= 0 ;
82 wndclass
.cbWndExtra
= 0 ;
83 wndclass
.hInstance
= hInstance
;
84 wndclass
.hIcon
= LoadIcon (hInstance
, APPNAME
) ;
85 wndclass
.hCursor
= LoadCursor (NULL
, IDC_ARROW
) ;
86 wndclass
.hbrBackground
= GetStockObject (WHITE_BRUSH
) ;
87 wndclass
.lpszMenuName
= APPNAME
;
88 wndclass
.lpszClassName
= APPNAME
;
90 // register the window class
91 if (!RegisterClass (&wndclass
)) {
95 hWnd
= CreateWindow ( // create the program's window here
96 APPNAME
, // class name
97 APPNAME
, // window name
98 WS_OVERLAPPEDWINDOW
, // window style
99 CW_USEDEFAULT
, // x position on screen
100 CW_USEDEFAULT
, // y position on screen
101 50, // width of window
102 50, // height of window
103 NULL
, // parent window handle (null = none)
104 NULL
, // menu handle (null = class menu)
105 hInstance
, // instance handle
106 NULL
) ; // lpstr (null = not used)
108 pWinApp
= AppGetObj( IWinApp
);
109 IWinApp_SetMainWnd( pWinApp
, hWnd
);
110 SafeRelease( pWinApp
);
112 ShowWindow (hWnd
, SW_SHOW
) ;
113 UpdateWindow (hWnd
) ; // send first WM_PAINT message
115 pMixer
= SoundInit();
117 //SoundPlayFile( argv[1], pMixer, 127, 64 );
119 pSample
= CreateSoundFileStreamer( pMixer
, argv
[1], pBuffer
, 65536, endItAll
, NULL
);
121 startOff
= atoi( argv
[2] );
122 ISndSample_SetPosition( pSample
, startOff
);
124 ISndSample_Play( pSample
);
126 nTimer
= SetTimer( hWnd
, 1, 60, NULL
); // send timer events every 60 milliseconds
127 while (GetMessage (&msg
, NULL
, 0, 0)) { // the message loop
128 //mprintf( "message loop\n" );
129 TranslateMessage( &msg
) ;
130 SoundRecur( pMixer
);
131 DispatchMessage( &msg
) ;
133 KillTimer( hWnd
, nTimer
);
137 TIMELOG_DUMP( "sndlog.txt" );
142 tResult LGAPI
AppCreateObjects(int argc
, const char * argv
[])
144 GenericApplicationCreate( argc
, argv
, "streamer", NULL
);