/***************************************************************************
                          MIDIWriter.h  -  description
                             -------------------
    begin                : Die Feb 8 2005
    copyright            : (C) 2005 by klaus frieler
    email                : kgf@omniversum.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef _LIBMELODY_MIDIWRITER_H
#define _LIBMELODY_MIDIWRITER_H

#include "types.h"
#include "Melody.h"
#include "jdkmidi/world.h"
#include "jdkmidi/filewrite.h"

using namespace jdkmidi;

class MIDIWriter
{
   static int signs[];
public:
   MIDIWriter(const string& fileName, const Melody* pMelody, const uchar chan, const uchar GMInst);
   ~MIDIWriter();

   bool     write();
   
   string   getErrText() const { return m_sErrText;}

protected:
   MIDIFileWrite                *m_pWriter;
   MIDIFileWriteStreamFileName  *m_pStream;
   string                        m_sFileName;
   const Melody*                 m_pMel;
   uchar                         m_nChannel;
   uchar                         m_nGMInst ;
   string                        m_sErrText;

   bool                          init();
   void                          cleanUp();
   bool                          writeHeader();
   bool                          writeSignatureTrack();
   bool                          writeTrack();
   
};
#endif
