From 0b986c0366f52073a6cf632fa337141161c7254c Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 8 Jul 2024 16:59:26 -0400 Subject: [PATCH] cwWaveTableBank.cpp : Implemented get_wave_table() and _report_map() --- cwWaveTableBank.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/cwWaveTableBank.cpp b/cwWaveTableBank.cpp index 3247a78..2aee1de 100644 --- a/cwWaveTableBank.cpp +++ b/cwWaveTableBank.cpp @@ -64,6 +64,22 @@ namespace cw wt_bank_t* _handleToPtr( handle_t h ) { return handleToPtr(h); } + void _report_map( const wt_map_t* map ) + { + for(unsigned i=0; imap[(j*midi::kMidiNoteCnt) + i]; + + cwLogPrint("%i:%1i ",j,wt != nullptr); + } + cwLogPrint("\n"); + } + + } + void _report( wt_bank_t* p ) { for(af_t* af = p->afList; af!=nullptr; af=af->link) @@ -91,7 +107,10 @@ namespace cw } } } - } + } + + if( p->wtMapN > 0 ) + _report_map( p->wtMapA ); } rc_t _destroy( wt_bank_t* p ) @@ -540,6 +559,32 @@ unsigned cw::wt_bank::instr_index( handle_t h, const char* instr_label ) const cw::wt_bank::wt_t* cw::wt_bank::get_wave_table( handle_t h, unsigned instr_idx, unsigned pitch, unsigned vel ) { + rc_t rc = kOkRC; + + wt_bank_t* p = _handleToPtr(h); + + if( instr_idx >= p->wtMapN ) + { + rc = cwLogError(kInvalidArgRC,"Invalid instr_idx %i",instr_idx); + goto errLabel; + } + + if( pitch >= midi::kMidiNoteCnt ) + { + rc = cwLogError(kInvalidArgRC,"Invalid MIDI pitch %i",pitch); + goto errLabel; + } + + if( vel >= midi::kMidiVelCnt ) + { + rc = cwLogError(kInvalidArgRC,"Invalid MIDI pitch %i",pitch); + goto errLabel; + } + + return p->wtMapA[ instr_idx ].map[ vel * midi::kMidiNoteCnt + pitch ]; + +errLabel: + cwLogError(rc,"Wave table lookup failed."); return nullptr; }