#ifndef __COMMON__
#define __COMMON__

#include <stdio.h>
#include <limits.h>

#include <Stk.h>
#include <RtAudio.h>
#include <SineWave.h>
#include <Noise.h>

#define DebugPcmOutArray(name, s16array, length)	\
{											\
	static FILE *fh = NULL;						\
	if(fh == NULL) {							\
		if((fh = fopen(name, "wb")) == NULL) {	\
			printf("file open error . %s ", name);	\
		}											\
	}													\
	if(fh != NULL) {									\
		fwrite(s16array, sizeof(short), length, fh);		\
	}													\
}

#define DebugPcmOut(name, s16)	\
{											\
	static FILE *fh = NULL;						\
	if(fh == NULL) {							\
		if((fh = fopen(name, "wb")) == NULL) {	\
			printf("file open error . %s ", name);	\
		}											\
	}													\
	if(fh != NULL) {									\
		fwrite(&s16, sizeof(short), 1, fh);		\
	}													\
}

#define dprintf(s,...)	 printf("%s:%d: " s, __func__, __LINE__,__VA_ARGS__)

#define DebugFile(name, str, ...)			\
{											\
	static FILE *fh = NULL;						\
	if(fh == NULL) {							\
		if((fh = fopen(name, "w")) == NULL) {	\
			printf("file open error . %s ", name);	\
		}											\
	}												\
	if(fh != NULL) {								\
		fprintf(fh, str, __VA_ARGS__);				\
	}												\
}

#endif // __COMMMON


