The Mud Puddle

Home of Jon "evincarofautumn" Purdy

pxtone.h

This is my best attempt at translating pixel's pxtone.h:

#ifdef PXTONEDLL_EXPORTS
#define DLLAPI __declspec(dllexport) // Declare for DLL export
#else
#define DLLAPI __declspec(dllimport) // Declare for DLL import
#endif

// We want C instead of C++.
#ifdef __cplusplus
extern "C"{
#endif

typedef BOOL (* PXTONEPLAY_CALLBACK)( long clock );

// pxtone functions follow ===================================


// Initialise pxtone.
BOOL DLLAPI pxtone_Ready(
    HWND hWnd,          // Please supply window handle
    long channel_num,   // Please specify the number of channels (1:Mono / 2:Stereo)
    long sps,           // Per-second sampling rate (11025 / 22050 / 44100)
    long bps,           // Beat count per 1 sample ( 8 / 16 )
    float buffer_sec,   // Song buffer size, used to play a song (0.1 recommended)
    BOOL bDirectSound,  // TRUE: Use DirectSound / FALSE: Use WAVEMAPPER.
    PXTONEPLAY_CALLBACK pProc // Function called for each sample.  Can be NULL.
); // pxtone declaration

// Reconfigure pxtone.
BOOL DLLAPI pxtone_Reset(
    HWND hWnd,
    long channel_num,
    long sps,
    long bps,
    float buffer_sec,
    BOOL bDirectSound,
    PXTONEPLAY_CALLBACK pProc
);

// pxtone generates a DirectSound pointer (LPDIRECTSOUND).
// Please be careful not to release DirectSound itself.
void DLLAPI *pxtone_GetDirectSound( void );

// Aquires the previous error string
const char DLLAPI* pxtone_GetLastError( void );

// Get the pxtone quality
void DLLAPI pxtone_GetQuality( long *p_channel_num, long *p_sps, long *p_bps, long *p_sample_per_buf ); // pxtone

// Release pxtone.
BOOL DLLAPI pxtone_Release( void );

// Load a song (from a resource file)
BOOL DLLAPI pxtone_Tune_Load(
    HMODULE hModule,       // If you are reading a resource from a module handle.
                           // It's no problem for this to be NULL.
    const char *type_name, // The resource type if you are reading from a resource.
                           // For reading external files, this is NULL.
    const char *file_name  // Resource file name or path and filename.
    );

// Load a song (from memory)
BOOL DLLAPI pxtone_Tune_Read( void* p, long size );

// Free a song
BOOL DLLAPI pxtone_Tune_Release( void );

// Play the song
BOOL DLLAPI pxtone_Tune_Start(
    long start_sample,     // Start position.  Stop and Fadeout mainly use these values.  0 is the first.
    long fadein_msec       // Fade-in time from this position (milliseconds).
    );

// Fade out playback starting on next sample.
long DLLAPI pxtone_Tune_Fadeout( long msec );

// Set the song volume.  Up to 1.0, 0.5 is half.
void DLLAPI pxtone_Tune_SetVolume( float v );

// Stop sampling for currently playing song
long DLLAPI pxtone_Tune_Stop( void );

// Determines whether playing.
BOOL DLLAPI pxtone_Tune_IsStreaming( void );

// Set playback looping ON / OFF.
void DLLAPI pxtone_Tune_SetLoop( BOOL bLoop );

// Get information about the song.
void DLLAPI pxtone_Tune_GetInformation( long *p_beat_num, float *p_beat_tempo, long *p_beat_clock, long *p_meas_num );

// Get start-of-repeat measure.
long DLLAPI pxtone_Tune_GetRepeatMeas( void );

// Get the effective performance measure (LAST event measure, if you do not have a final measure)
long DLLAPI pxtone_Tune_GetPlayMeas(   void );

// Get the name of the song.
const char DLLAPI* pxtone_Tune_GetName(    void );

// Get the song comments.
const char DLLAPI* pxtone_Tune_GetComment( void );


// Specifies address to which to write playback buffer
BOOL DLLAPI pxtone_Tune_Vomit(
    void* p,         // The address of the playback buffer
    long sample_num  // Number of samples to write
    );

// Returns:  TRUE if you have not yet continued, FALSE otherwise
// 1. If you use this function, please set buffer_sec of pxtone_Ready() to 0.
//    pxtone streaming feature is disabled.
// 2. After a call to this function, call pxtone_Tune_Start() to load song.
// 3. sample_num sample size is not the sample number.
//    Ex)  11025hz 2ch 8bit will spit out a double value, even though sample_num
//         specifies 11025.  22050 bytes are written to the playback buffer.
// 4. Streaming functions are similarly valid, e.g. pxtone_Tune_Fadeout().


#ifdef __cplusplus
}
#endif