spek

Acoustic spectrum analyser https://github.com/alexkay/spek spek.cc
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

spek-events.cc (936B)


      1 #include "spek-events.h"
      2 
      3 //IMPLEMENT_DYNAMIC_CLASS(SpekHaveSampleEvent, wxEvent)
      4 DEFINE_EVENT_TYPE(SPEK_HAVE_SAMPLE)
      5 
      6 SpekHaveSampleEvent::SpekHaveSampleEvent(int bands, int sample, float *values, bool free_values)
      7     : wxEvent(), bands(bands), sample(sample), values(values), free_values(free_values)
      8 {
      9     SetEventType(SPEK_HAVE_SAMPLE);
     10 }
     11 
     12 SpekHaveSampleEvent::SpekHaveSampleEvent(const SpekHaveSampleEvent& other) : wxEvent(other)
     13 {
     14     SetEventType(SPEK_HAVE_SAMPLE);
     15     this->bands = other.bands;
     16     this->sample = other.sample;
     17     if (other.values) {
     18         this->values = (float *)malloc(this->bands * sizeof(float));
     19         memcpy(this->values, other.values, this->bands * sizeof(float));
     20         this->free_values = true;
     21     } else {
     22         this->values = NULL;
     23         this->free_values = false;
     24     }
     25 }
     26 
     27 SpekHaveSampleEvent::~SpekHaveSampleEvent()
     28 {
     29     if (this->free_values) {
     30         free(this->values);
     31     }
     32 }