Copyright (C) Kevin Larke 2009-2020

This file is part of libcm.

libcm 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 3 of the License, or (at your option) any later version.

libcm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See the GNU General Public License distributed with the libcm package or look here: .


cmDspPreset : 'snap' unit state store/recall implementation.

typedef struct _cmDspPreVar_str
{
  unsigned                 symId;
  cmDspValue_t             value;
  struct _cmDspPreVar_str* link;
} _cmDspPresetVar_t;

typedef struct _cmDspPresetInst_str
{
  unsigned                     symId;
  struct _cmDspPresetInst_str* link;
  _cmDspPresetVar_t*           list;
} _cmDspPresetInst_t;

typedef struct _cmDspPresetPre_str
{
  unsigned                    symId;
  struct _cmDspPresetPre_str* link;
  _cmDspPresetInst_t*         list;
  _cmDspPresetInst_t*         ip;
} _cmDspPresetPre_t;

typedef struct _cmDspPresetGrp_str
{
  unsigned                    symId;
  struct _cmDspPresetGrp_str* link;
  _cmDspPresetPre_t*          list;
  _cmDspPresetPre_t*          pp;
} _cmDspPresetGrp_t;

typedef struct 
{
  cmErr_t*           err;
  cmLHeapH_t         lhH;
  cmSymTblH_t        stH;    
  _cmDspPresetGrp_t* list;
  _cmDspPresetGrp_t* gp;
  const cmChar_t*    dfltPathJsFn;
  const cmChar_t*    dfltPathCsvFn;
} cmDspPresetMgr_t;

void      _cmDspPresetAlloc(  cmDspPresetMgr_t* p );
cmDspRC_t _cmDspPresetLoad(   cmDspPresetMgr_t* p, cmCtx_t* ctx, cmErr_t* err, cmLHeapH_t lhH, cmSymTblH_t stH, const cmChar_t* fnPrefixStr );
cmDspRC_t _cmDspPresetUnload( cmDspPresetMgr_t* p, cmCtx_t* ctx );

cmDspRC_t _cmDspPresetRead(     cmDspPresetMgr_t* p, cmCtx_t* ctx, const cmChar_t* fn );
cmDspRC_t _cmDspPresetWrite(    cmDspPresetMgr_t* p, cmCtx_t* ctx, const cmChar_t* fn );
cmDspRC_t _cmDspPresetWriteCsv( cmDspPresetMgr_t* p, cmCtx_t* ctx, const cmChar_t* fn );

unsigned        _cmDspPresetGroupCount( cmDspPresetMgr_t* p );
unsigned        _cmDspPresetGroupSymId( cmDspPresetMgr_t* p, unsigned groupIdx );
const cmChar_t* _cmDspPresetGroupLabel( cmDspPresetMgr_t* p, unsigned groupIdx );
cmDspRC_t       _cmDspPresetGroupJsonList(  cmDspPresetMgr_t* p, cmJsonH_t* jsHPtr );

unsigned        _cmDspPresetPresetCount( cmDspPresetMgr_t* p, unsigned groupIdx );
unsigned        _cmDspPresetPresetSymId( cmDspPresetMgr_t* p, unsigned groupIdx, unsigned presetIdx );
const cmChar_t* _cmDspPresetPresetLabel( cmDspPresetMgr_t* p, unsigned groupIdx, unsigned presetIdx );
cmDspRC_t       _cmDspPresetPresetJsonList( cmDspPresetMgr_t* p, cmJsonH_t* jsHPtr, unsigned groupSymId );    

cmDspRC_t _cmDspPresetCreatePreset(    cmDspPresetMgr_t* p, const cmChar_t* groupLabel, const cmChar_t* presetLabel );
cmDspRC_t _cmDspPresetCreateInstance(  cmDspPresetMgr_t* p, unsigned instSymId );
cmDspRC_t _cmDspPresetCreateVar(       cmDspPresetMgr_t* p, unsigned varSymId, const cmDspValue_t* valPtr );

cmDspRC_t _cmDspPresetRecallPreset(    cmDspPresetMgr_t* p, const cmChar_t* groupLabel, const cmChar_t* presetLabel );
cmDspRC_t _cmDspPresetRecallInstance(  cmDspPresetMgr_t* p, unsigned instSymId );
cmDspRC_t _cmDspPresetRecallVar(       cmDspPresetMgr_t* p, unsigned varSymId, cmDspValue_t* valPtr );