cwWaveTableBank.cpp : PV map now fills in missing velocities between sampled velocities.

This commit is contained in:
kevin 2024-08-02 13:37:35 -04:00
parent c87fc2a9e4
commit 645e67fee4

View File

@ -207,8 +207,14 @@ namespace cw
rc_t _create_instr_pv_map( instr_t* instr ) rc_t _create_instr_pv_map( instr_t* instr )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
instr->pvM = mem::allocZ<multi_ch_wt_seq_t*>(midi::kMidiVelCnt * midi::kMidiNoteCnt );
// each row contains the velocities for a given pitch
instr->pvM = mem::allocZ<multi_ch_wt_seq_t*>(midi::kMidiNoteCnt * midi::kMidiVelCnt );
for(unsigned i=0; i<instr->pitchN; ++i) for(unsigned i=0; i<instr->pitchN; ++i)
{
unsigned vel0 = 0;
for(unsigned j=0; j<instr->pitchA[i].velN; ++j) for(unsigned j=0; j<instr->pitchA[i].velN; ++j)
{ {
unsigned pitch = instr->pitchA[i].midi_pitch; unsigned pitch = instr->pitchA[i].midi_pitch;
@ -220,8 +226,30 @@ namespace cw
if( vel >= midi::kMidiVelCnt ) if( vel >= midi::kMidiVelCnt )
rc = cwLogError(kInvalidArgRC,"An invalid velocity value (%i) was encountered.",vel); rc = cwLogError(kInvalidArgRC,"An invalid velocity value (%i) was encountered.",vel);
instr->pvM[(vel*midi::kMidiNoteCnt) + pitch ] = &instr->pitchA[i].velA[j].mc_seq; multi_ch_wt_seq_t* mcs = &instr->pitchA[i].velA[j].mc_seq;
// if there is a gap between vel0 and vel
if( vel0 > 0 )
{
// find the center of the gap
unsigned vel_c = vel0 + (vel-vel0)/2;
// vel0:vel_c = mcs0
for(unsigned v=vel0+1; v<=vel_c; ++v)
{
instr->pvM[(v*midi::kMidiNoteCnt) + pitch ] = instr->pvM[(vel0*midi::kMidiNoteCnt) + pitch ];
}
// vel_c+1:vel-1 = mcs
for(unsigned v=vel_c+1; v<vel; ++v)
{
instr->pvM[(v*midi::kMidiNoteCnt) + pitch ] = mcs;
}
}
instr->pvM[(vel*midi::kMidiNoteCnt) + pitch ] = mcs;
vel0 = vel;
}
} }
if( rc != kOkRC ) if( rc != kOkRC )