예제 #1
0
SynthNote*  AUInstrumentBase::VoiceStealing(UInt32 inFrame, bool inKillIt)
{

#if DEBUG_PRINT
	printf("enter voice stealing\n");
#endif
	// free list was empty so we need to kill a note.
	UInt32 startState = inKillIt ? kNoteState_FastReleased : kNoteState_Released;
	for (UInt32 i = startState; i <= startState; --i)
	{
#if DEBUG_PRINT
		printf(" steal state %d\n", i);
#endif
		UInt32 numGroups = Groups().GetNumberOfElements();
		for (UInt32 j = 0; j < numGroups; ++j)
		{
			SynthGroupElement *group = (SynthGroupElement*)Groups().GetElement(j);
#if DEBUG_PRINT
			printf(" steal group %d   size %d\n", j, group->mNoteList[i].Length());
#endif
			if (group->mNoteList[i].NotEmpty()) {
#if DEBUG_PRINT
				printf("not empty %d %d\n", i, j);
#endif
				SynthNote *note = group->mNoteList[i].FindMostQuietNote();
				if (inKillIt) {
#if DEBUG_PRINT
					printf("--=== KILL ===---\n");
#endif
					note->mRelativeKillFrame = inFrame;
					note->Kill(inFrame);
					group->mNoteList[i].RemoveNote(note);
					if (i != kNoteState_FastReleased)
						DecNumActiveNotes();
					return note;
				} else {
#if DEBUG_PRINT
					printf("--=== FAST RELEASE ===---\n");
#endif
					group->mNoteList[i].RemoveNote(note);
					note->FastRelease(inFrame);
					group->mNoteList[kNoteState_FastReleased].AddNote(note);
					DecNumActiveNotes(); // kNoteState_FastReleased counts as inactive for voice stealing purposes.
					return NULL;
				}
			}
		}
	}
#if DEBUG_PRINT
	printf("no notes to steal????\n");
#endif
	return NULL; // It should be impossible to get here. It means there were no notes to kill in any state. 
}
예제 #2
0
void		AUInstrumentBase::AddFreeNote(SynthNote* inNote)
{
	if (inNote->mState != kNoteState_FastReleased) 
		DecNumActiveNotes();
#if DEBUG_PRINT
	printf("AUInstrumentBase::AddFreeNote   mNumActiveNotes %lu\n", mNumActiveNotes);
#endif
	mFreeNotes.AddNote(inNote);
}
예제 #3
0
void		AUInstrumentBase::AddFreeNote(SynthNote* inNote)
{
	// Fast-released notes are already considered inactive and have already decr'd the active count
	if (inNote->GetState() != kNoteState_FastReleased) {
		DecNumActiveNotes();
	}
#if DEBUG_PRINT_NOTE
	else {
			printf("AUInstrumentBase::AddFreeNote: adding fast-released note %p\n", inNote);
	}
	printf("AUInstrumentBase::AddFreeNote (%p)  mNumActiveNotes %lu\n", inNote, mNumActiveNotes);
#endif
	mFreeNotes.AddNote(inNote);
}