// wavLibrary.h  P. Conrad   CISC181 Fall 2005
// Routines for writing WAV files from sine waves

// @@@ ADD COMMENT HERE.. 
// Modified by @@@ insert your name, date, lab section
// for project 1b for CISC181, Fall 2005

#include <iostream>
using namespace std;


// the following header files are needed for writing binary files
// they provide the functions open() and write(), as well as O_CREAT, O_RDWR

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <stdio.h> // for perror

#include <cmath>   // for sin, floor
#include <cstdlib> // for atoi, atof


#include "endian.h"


void writeWAVheader(int numSamples, int samplesPerSecond, int fd);

void  writeSilenceSamples(int fd, double duration);
void  writeSineWaveSamples(int fd, double duration, double freq1 );
void  writeNoiseSamples(int fd, double duration, double volume);

double lengthOfC(double ditDuration,double dahDuration,double spaceInsideChars);
double lengthOfI(double ditDuration,double dahDuration,double spaceInsideChars);
double lengthOfS(double ditDuration,double dahDuration,double spaceInsideChars);

// @@@ START REMOVE
double lengthOf1(double ditDuration,double dahDuration,double spaceInsideChars);
double lengthOf8(double ditDuration,double dahDuration,double spaceInsideChars);
// @@@ END REMOVE

void writeC(int fd, double ditDuration, double dahDuration, double spaceInsideChars, double morseCodeFrequency);
void writeI(int fd, double ditDuration, double dahDuration, double spaceInsideChars, double morseCodeFrequency);
void writeS(int fd, double ditDuration, double dahDuration, double spaceInsideChars, double morseCodeFrequency);

// @@@ START REMOVE
void write1(int fd, double ditDuration, double dahDuration, double spaceInsideChars, double morseCodeFrequency);
void write8(int fd, double ditDuration, double dahDuration, double spaceInsideChars, double morseCodeFrequency);

// @@@ END REMOVE

void  writeDTMFSamples(int fd, double duration, int freq1, int freq2);
void writeDTMFTones(int fd, double toneDuration, char c);

// defining a const as "extern" is like a function prototype
// the actual definition can only be defined ONCE in a single .o file
// but the "extern" definition can be included as many times as you need

extern const int DTMF1a; extern const int DTMF1b;
extern const int DTMF2a; extern const int DTMF2b;
extern const int DTMF3a; extern const int DTMF3b;

// @@@ TODO: finish the table of constants
// @@@ NOTE: you must add extern definition to the .h file also!

extern const int DTMF_star_a;  extern const int DTMF_star_b;
extern const int DTMF0a;       extern const int DTMF0b;
extern const int DTMF_pound_a; extern const int DTMF_pound_b;

extern const int dialTone_a; extern const int dialTone_b;

//  @@@ TODO: add constants for the busy signal frequencies
//  @@@ and the on/off durations.   


