#ifndef _NOISESTR_H_
#define _NOISESTR_H_

/* Private Noise header file, shared by library and server.  The
 * server should insure that _NOISE_SERVER_ is defined before
 * including this file.
 */

#ifndef XMD_H
#include "../Xmd.h"
#endif
#ifndef _NOISE_H_
#include "noise.h"
#endif

#define ACORN_NOISE_PROTOCOL_NAME	"Acorn-Noise"
#define ACORN_NOISE_MAJOR_VERSION	1
#define ACORN_NOISE_MINOR_VERSION	0

/*
 * Requests and replies
 */

#define NOISE CARD32

typedef struct _NoiseQueryVersion {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseQueryVersion */
    CARD16	length B16;		/* 2 */
    CARD32	pad0 B32;
} xNoiseQueryVersionReq;
#define sz_xNoiseQueryVersionReq	8

typedef struct {
    BYTE	type;			/* X_Reply */
    CARD8	noiseReqType;		/* always X_NoiseQueryVersion */
    CARD16	sequenceNumber B16;
    CARD32	length B32;		/* 0 */
    CARD16	majorVersion B16;	/* major version of NOISE protocol */
    CARD16	minorVersion B16;	/* minor version of NOISE protocol */
    BOOL	present;		/* 1 if the extension is present */
    BYTE	pad0, pad1, pad2;
    CARD32	pad3 B32;
    CARD32	pad4 B32;
    CARD32	pad5 B32;
    CARD32	pad6 B32;
} xNoiseQueryVersionReply;
#define sz_xNoiseQueryVersionReply	32

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseEnable */
    CARD16	length B16;		/* 2 */
    CARD8	mode;			/* NoiseOff, NoiseBell, NoiseOn */
    BYTE	pad0, pad1, pad2;
} xNoiseEnableReq;
#define sz_xNoiseEnableReq	8

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseCreate */
    CARD16	length B16;		/* 3 */
    NOISE	noise B32;		/* noise ID */
    CARD32	sampleRate B32;		/* sample rate in Hz */
} xNoiseCreateReq;
#define sz_xNoiseCreateReq	12

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseReset */
    CARD16	length B16;		/* 3 */
    NOISE	noise B32;		/* noise ID */
    CARD32	sampleRate B32;		/* sample rate in Hz */
} xNoiseResetReq;    
#define sz_xNoiseResetReq	12

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseDestroy */
    CARD16	length B16;		/* 2 */
    NOISE	noise B32;		/* noise ID */
} xNoiseDestroyReq;
#define sz_xNoiseDestroyReq	8

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseAppend*/
    CARD16	length B16;		/* 3+(n+p)/4 */
    NOISE	noise B32;		/* noise ID */
    CARD8	sampleSize;		/* 8, 16 or 32 */
    CARD8	pad0;
    CARD16	sampleLength B16;	/* == number of sampleSize units, not bytes */
    /*
     * Followed by:-
     * n bytes of sample data, where n = (sampleSize * sampleLength) / 8
     * p bytes of padding, to round up to a 4byte total.
     */
} xNoiseAppendReq;
#define sz_xNoiseAppendReq 12

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoisePlay*/
    CARD16	length B16;		/* 3 */
    NOISE	noise B32;		/* noise ID */
    CARD8	volume;			/* 0-100 */
    CARD8	pad0, pad1, pad2;
} xNoisePlayReq;
#define sz_xNoisePlayReq 12

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseInfo*/
    CARD16	length B16;		/* 1 */
} xNoiseInfoReq;
#define sz_xNoiseInfoReq 4

typedef struct {
    BYTE	type;			/* X_Reply */
    CARD8	noiseReqType;		/* always X_NoiseInfo */
    CARD16	sequenceNumber B16;
    CARD32	length B32;		/* 0 */
    CARD32	minRate B32;		/* minimum sample rate */
    CARD32	maxRate B32;		/* maximum sample rate */
    CARD32	bestRate B32;		/* optimum sample rate */
    CARD8	bestFormat;		/* 8, 16 or 32 */
    CARD8	rateMismatch;		/* NoiseNearest or NoiseInterpolate */
    CARD8	overlap;		/* Noise{Block|Discard|Sequence|Merge} */
    CARD8	status;			/* NoiseOff, NoiseBell or NoiseOn */
    CARD32	pad0 B32;
    CARD32	pad1 B32;
} xNoiseInfoReply;
#define sz_xNoiseInfoReply	32

typedef struct {
    CARD8	reqType;		/* always NoiseReqCode */
    CARD8	noiseReqType;		/* always X_NoiseBestSample*/
    CARD16	length B16;		/* 2 */
    CARD32	sampleRate B32;		/* desired sample rate */
} xNoiseBestSampleReq;
#define sz_xNoiseBestSampleReq 8

typedef struct {
    BYTE	type;			/* X_Reply */
    CARD8	noiseReqType;		/* always X_NoiseBestSample */
    CARD16	sequenceNumber B16;
    CARD32	length B32;		/* 0 */
    CARD32	bestSample B32;		/* nearest supported sample rate */
    CARD32	pad0 B32;
    CARD32	pad1 B32;
    CARD32	pad2 B32;
    CARD32	pad3 B32;
    CARD32	pad4 B32;
} xNoiseBestSampleReply;
#define sz_xNoiseBestSampleReply 32


#endif				/* _NOISESTR_H_ */
