/*==========================================================================
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File:DSStream.h
* Content:DirectSound Stream Sample Application Header
*
***************************************************************************/
#ifndef __DSSTREAM_INCLUDED__
#define __DSSTREAM_INCLUDED__
#include <dsound.h>
#include "resource.h"
#include "debug.h"
#define NUM_PLAY_NOTIFICATIONS4// number of notifications *not* including stop.
#define DSSTREAM_STOPF_NOREOPEN0x0001
#define DSSTREAM_STOPF_NOEXIT0x0002// Prevent the stop code from calling exit
#define ERR_WAVE_OPEN_FAILED-100
#define ERR_WAVE_INVALID_FORMAT-101
#define ERR_CREATEDSB_FAILED-102
#define ERR_WAVE_CORRUPTED_FILE-103
#define BORDER_SPACE_CX10
#define BORDER_SPACE_CY10
#define CONTROL_SPACE_CX4
#define CONTROL_SPACE_CY4
#define TEXT_SPACE_CY0
#define TEXT_SPACE_CX2
#define BUTTON_CX70
#define BUTTON_CY32
#define CHECK_CX70
#define CHECK_CY22
#define BUTTON_SPACE_CY6
#define PAN_TEXT_CX 140
#define VOL_TEXT_CX 140
#define FREQ_TEXT_CX 140
#define PROG_TEXT_CX 140
#define PAN_TB_CX200
#define PAN_TB_CY30
#define VOL_TB_CX200
#define VOL_TB_CY30
#define FREQ_TB_CX200
#define FREQ_TB_CY30
#define PROG_TB_CX200
#define PROG_TB_CY30
// The values for PAN may change in range...
//#define PAN_TB_MIN 0
//#define PAN_TB_MAX 2000
//#define PAN_TB_CENTER 1000
//#define PAN_MULTIPLIER 1
#define PAN_MIN 0
#define PAN_MAX 800
#define PAN_CENTER 400
#define PAN_SHIFT (-400)
#define PAN_PAGESIZE 10
#define PAN_DIV 10
#define PAN_MULT 10
//#define PAN_DSB_MIN (-400)
//#define PAN_DSB_MAX 400
//#define PAN_DSB_CENTER0
//#define VOL_TB_MIN 0
//#define VOL_TB_MAX 1000
//#define VOL_MULTIPLIER 1
#define VOL_SHIFT (-400)
#define VOL_MIN0
#define VOL_MAX 400
#define VOL_PAGESIZE 10
#define VOL_DIV 10
#define VOL_MULT 10
#define FREQ_MIN441
#define FREQ_MAX4410
#define FREQ_PAGESIZE100
#define FREQ_MULTIPLIER10
#define PROG_MIN0
#define PROG_MAX10000
#define PROG_MULTIPLIER 100
/* WAVE I/O subsystem defines */
#define WAVEVERSION 1
#ifndef ER_MEM
#define ER_MEM 0xe000
#endif
#ifndef ER_CANNOTOPEN
#define ER_CANNOTOPEN 0xe100
#endif
#ifndef ER_NOTWAVEFILE
#define ER_NOTWAVEFILE 0xe101
#endif
#ifndef ER_CANNOTREAD
#define ER_CANNOTREAD 0xe102
#endif
#ifndef ER_CORRUPTWAVEFILE
#define ER_CORRUPTWAVEFILE0xe103
#endif
#ifndef ER_CANNOTWRITE
#define ER_CANNOTWRITE0xe104
#endif
/* Streaming communication defines and structures */
#define WM_DSSTREAM_DONEWM_USER + 0x100/* Make our own app messages */
#define WM_DSSTREAM_DEBUGWM_USER + 0x101
#define WM_DSSTREAM_PROGRESSWM_USER + 0x102
#define DEBUGF_PLAYPOSITION0x0300
#define DEBUGF_WRITEPOSITION0x0301
#define DEBUGF_NEXTWRITE0x0302
#define DEBUGF_SKIP0x0303
/*
* This structure keeps all the data that the TimeFunc callback uses in one
* place. In this implementation, that means the global data segement. This
* is setup so that if you wanted to put your callback in a DLL, all you'd need
* to do is pass the address of this structure as a parameter.
*/
typedef struct waveinfoca_tag
{
WAVEFORMATEX *pwfx; /* Wave Format data structure */
HMMIO hmmio; /* MM I/O handle for the WAVE */
MMCKINFO mmck; /* Multimedia RIFF chunk */
MMCKINFO mmckInRIFF; /* Use in opening a WAVE file */
LPDIRECTSOUNDBUFFER lpDSBStreamBuffer; /* Points to DirectSoundBuffer */
DWORD dwBufferSize; /* Size of the entire buffer */
DWORD dwNotifySize;// size of each notification period.
DWORD dwNextWriteOffset; /* Offset to next buffer segment */
DWORD dwProgress; /* Used with above to show prog. */
DWORD dwLastPos;// the last play position returned by GetCurrentPos().
//DWORD dwBytesRemaining; /* Bytes 'til timer shutdown */
BOOL bDonePlaying; /* Signals early abort to timer */
BOOL bLoopFile; /* Should we loop playback? */
BOOL bFoundEnd; /* Timer found file end */
} WAVEINFOCA, *LPWAVEINFOCA;
// Notify events. We deal with 2 notifications.
HANDLE hNotifyEvent[2];
int SetupNotifications(void);
DWORD HandleNotifications(LPVOID);
/* Function declarations */
LRESULT CALLBACK MainWindowProc( HWND, unsigned, WPARAM, LPARAM );
BOOL CALLBACK DLG_About( HWND, UINT, WPARAM, LPARAM );
void CALLBACK TimeFunc( UINT, UINT, DWORD, DWORD, DWORD );
BOOL CALLBACK DSEnumDlgProc( HWND, UINT, WPARAM, LPARAM );
BOOL CALLBACK DSEnumProc( LPGUID, LPSTR, LPSTR, LPVOID );
void ErrorMessageBox( UINT, DWORD );
void HandlePanScroll( int, int );
void HandleVolScroll( int, int );
void HandleFreqScroll( int, int );
void ResetWavePlayer( void );
void UpdateFromControls( void );
int CreateChildren( RECT );
int HandleCommDlgError( DWORD );
int StreamBufferSetup( void );
BOOL DoDSoundEnumerate( LPGUID );
int WaveOpenFile(char *, HMMIO *, WAVEFORMATEX **, MMCKINFO *);
int WaveStartDataRead(HMMIO *, MMCKINFO *, MMCKINFO *);
int WaveReadFile(HMMIO, UINT, BYTE *, MMCKINFO *, UINT *);
int WaveCloseReadFile(HMMIO *, WAVEFORMATEX **);
int WaveCreateFile(char *, HMMIO *, WAVEFORMATEX *, MMCKINFO *, MMCKINFO *);
int WaveStartDataWrite(HMMIO *, MMCKINFO *, MMIOINFO *);
int WaveWriteFile(HMMIO, UINT, BYTE *, MMCKINFO *, UINT *, MMIOINFO *);
int WaveCloseWriteFile(HMMIO *, MMCKINFO *, MMCKINFO *, MMIOINFO *, DWORD);
int WaveLoadFile(char *, UINT *, DWORD *, WAVEFORMATEX **, BYTE **);
int WaveSaveFile(char *, UINT, DWORD, WAVEFORMATEX *, BYTE *);
int WaveCopyUselessChunks(HMMIO *, MMCKINFO *, MMCKINFO *, HMMIO *,
MMCKINFO *, MMCKINFO *);
BOOL riffCopyChunk(HMMIO, HMMIO, const LPMMCKINFO);
#endif /* __DSSTREAM_INCLUDED__ */