#ifndef _FNotes__H
#define _FNotes__H

#include "TimTypes.h"
#include "kernel.h"

void Notes_SetPolyphony(NoteHandler*, uint32_t polyphony);
void Notes_PreClearAllNotes(NoteHandler*);
void Notes_ClearAllNotes(NoteHandler*);
Note* Notes_GetNewNote(NoteHandler*, Channel*);
void Notes_MoveNoteToVirtualPool(NoteHandler* pHNotes, Note* pNote);
void Notes_Refresh(NoteHandler*);
void Notes_BuildActiveNotesList(NoteHandler*);
void Note_SetStreamInfo(Note*);
void Note_PreApplyNoteAction(Note*, int action);
void Note_ApplyNoteAction(Note*, int action);
void Note_ClearNote(Note*);
void Notes_PreActOnDuplicateNotes
	( NoteHandler* pHNotes
	, uint8_t      action
	, Channel*     pChannel
	, uint8_t      inst_note
	, uint8_t      inst_id
	, uint8_t      smp_id
	, uint8_t      check_type
	);
void Notes_ActOnDuplicateNotes
	( NoteHandler* pHNotes
	, uint8_t      action
	, Channel*     pChannel
	, uint8_t      inst_note
	, uint8_t      inst_id
	, uint8_t      smp_id
	, uint8_t      check_type
	);
int Process_Envelope
	( const NoteHandler* pHNotes
	, const Envelope* pEnv
	, uint32_t* restrict pticks  // Updated on exit
	, uint32_t* restrict ppos    // Updated on exit
	, uint32_t* restrict pflags  // On exit 1 if envelope complete, 0 otherwise
	);

#endif
