0

This seems like a fairly complex problem to me, but I'm new to c++. I'm attempting to read multiple wave files, do stuff to them, and write the result to new files. The stuff i do to them could include mixing them together or processing them separately in any number of ways to produce one or more new wav files. So far, i am attempting to use the following class to manage them with:

class wavObj {
public:
    char                    RIFF_ID[4];                 // 4 bytes, RIFF Header      Magic header
    uint32_t                RIFF_Size;                  // 4 bytes, RIFF Chunk Size
    char                    RIFF_WAVE[4];               // 4 bytes, WAVE Header
    char                    fmt_ID[4];                  // 4 bytes, FMT header
    uint32_t                fmt_Size;                   // 4 bytes, Size of the fmt chunk
    uint16_t                fmt_AudioFormat;            // 2 bytes, Audio format 1=PCM,6=mulaw,7=alaw, 257=IBM Mu-Law, 258=IBM A-Law, 259=ADPCM 
    uint16_t                fmt_NumOfChan;              // 2 bytes, Number of channels 1=Mono 2=Sterio
    uint32_t                fmt_SamplesPerSec;          // 4 bytes, Sampling Frequency in Hz
    uint32_t                fmt_bytesPerSec;            // 4 bytes, bytes per second
    uint16_t                fmt_blockAlign;             // 2 bytes, 2=16-bit mono, 4=16-bit stereo
    uint16_t                fmt_bitsPerSample;          // 2 bytes, Number of bits per sample
    uint16_t                fmt_cbSize;                 // 2 bytes, Extension size for high bit depth stuff
    uint16_t                fmt_wValidBitsPerSample;    // 2 bytes, wav may not use all fmt_bitsPerSample. this tells how many are actually used.
    uint32_t                fmt_dwChannelMask;          // 4 bytes, 
    char                    fmt_SubFormat[16];          // 16 bytes, 
    char                    data_ID[4];                 // 4 bytes, "data"  string   
    uint32_t                data_Size;                  // 4 bytes, Sampled data length
    vector<unsigned char>   dataBuffer;                 // the data (of all sorts of fun sizes)

    int loadFile( const char *filePath );
    void displayHeader();

};

Reading data from a file into this class has been pretty straightforward, but writing binary to a file is complicated by the vector. My question is, would it be easier/safer/more efficient to serialize the vector, or to go through the process of writing constructors and destructors to manage a new/delete situation for the data of the wave file. Or is there a better way entirely to manage and manipulate many wav files? I'm not interested in a library to help me, I am doing this mostly as a learning experience.

4

0 回答 0