shithub: leaf

Download patch

ref: 84569b6c304057cb4fe91127cf387e75ced66db0
parent: 5311128d625468f22f7f4b7b93672ef8372bbff7
author: Matthew Wang <Matthew@nat-oitwireless-inside-vapornet100-10-9-74-35.princeton.edu>
date: Tue Dec 10 08:32:14 EST 2019

add getNumActiveVoices to poly

--- a/LEAF/Inc/leaf-midi.h
+++ b/LEAF/Inc/leaf-midi.h
@@ -108,6 +108,7 @@
     void    tPoly_tickPitchBend(tPoly* const);
     
     int     tPoly_getNumVoices(tPoly* const);
+    int     tPoly_getNumActiveVoices(tPoly* const);
     float   tPoly_getPitch(tPoly* const, uint8_t voice);
     int     tPoly_getKey(tPoly* const, uint8_t voice);
     int     tPoly_getVelocity(tPoly* const, uint8_t voice);
--- a/LEAF/Src/leaf-midi.c
+++ b/LEAF/Src/leaf-midi.c
@@ -303,6 +303,12 @@
     return poly->numVoices;
 }
 
+int tPoly_getNumActiveVoices(tPoly* const polyh)
+{
+    _tPoly* poly = *polyh;
+    return tStack_getSize(&poly->stack);
+}
+
 float tPoly_getPitch(tPoly* const polyh, uint8_t voice)
 {
     _tPoly* poly = *polyh;