// ----
// ---- file   : AR_Sound.h
// ---- author : Bastian Spiegel <bs@tkscript.de>
// ---- legal  : (c) 2017 by Bastian Spiegel. 
// ----          Distributed under terms of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL). See 
// ----          http://www.gnu.org/licenses/licenses.html#LGPL or COPYING for further information.
// ----
// ---- info   : This is part of the "tkanalogrytm" plugin.
// ----
// ---- changed: 21Aug2017
// ----
// ----
// ----

#ifndef __TK_AR_SOUND_H__
#define __TK_AR_SOUND_H__

YG("analogrytm")


/* @class AR_Sound,Object
 */
YC class AR_Sound : public YAC_Object {

//#define AR_SOUND_SYX_SZ        YCI AR_SOUND_SYX_SZ
//#define AR_SOUND_SZ            YCI AR_SOUND_SZ

  public:
   sU8 syx[AR_SOUND_SYX_SZ];
   sU8 raw[AR_SOUND_SZ];

   sU8 *current_buf; // points to either syx or raw buffer, whichever was last written

  public:
   AR_Sound(void);
   ~AR_Sound();

   YAC(AR_Sound);

  public:
   void YAC_VCALL yacOperator (sSI _cmd, YAC_Object *_robj, YAC_Value *_r);


   YM sUI getRequiredSizeSyx (void);
   YM sUI getRequiredSizeRaw (void);

   // 0=none, 1=syx, 2=raw
   YM sSI getCurrentDataIdx (void);

   YM void saveSyxToStream (YAC_Object *_ofs);
   YM void saveRawToStream (YAC_Object *_ofs);

   YM sBool loadSyxFromStream (YAC_Object *_ifs);
   YM sBool loadRawFromStream (YAC_Object *_ifs);

   YM sBool addSoundRequestX (YAC_Buffer *_d, sUI _devId, sUI _soundNr);

   YM sBool syxToRaw (YAC_Buffer *_s);

   YM sBool copyFromKitTrack (YAC_Object *_kit, sUI _srcTrackIdx);

   YM sBool sendSound (YAC_Buffer *_d, sUI _devId, sUI _soundNr, sBool _bEditBuf);

   // Return reference to 'raw' array in 'ret'
   YM sBool getRawBuffer (YAC_Buffer *_ret);
};


#endif // __TK_AR_SOUND_H__
