1 /* CountEventConsumer.h 2 * -------------------- 3 * A simple MIDI consumer that counts incoming MIDI events. 4 * 5 * Copyright 2013, Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Revisions by Pete Goodeve 9 * 10 * Copyright 1999, Be Incorporated. All Rights Reserved. 11 * This file may be used under the terms of the Be Sample Code License. 12 */ 13 #ifndef COUNTEVENTCONSUMER_H 14 #define COUNTEVENTCONSUMER_H 15 16 #include <MidiConsumer.h> 17 #include <SupportDefs.h> 18 19 class CountEventConsumer : public BMidiLocalConsumer 20 { 21 public: CountEventConsumer(const char * name)22 CountEventConsumer(const char* name) 23 : 24 BMidiLocalConsumer(name), 25 fEventCount(0) 26 {} Reset()27 void Reset() 28 { 29 fEventCount = 0; 30 } CountEvents()31 int32 CountEvents() 32 { 33 return fEventCount; 34 } 35 Data(uchar *,size_t,bool,bigtime_t)36 void Data(uchar*, size_t, bool, bigtime_t) 37 { 38 atomic_add(&fEventCount, 1); 39 } 40 41 private: 42 int32 fEventCount; 43 }; 44 45 #endif /* COUNTEVENTCONSUMER_H */ 46