EM.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Silvet
5 
6  A Vamp plugin for note transcription.
7  Centre for Digital Music, Queen Mary University of London.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SILVET_EM_H
17 #define SILVET_EM_H
18 
19 #include <vector>
20 
21 class InstrumentPack;
22 
23 class EM
24 {
25 public:
26  EM(const InstrumentPack *pack, bool useShifts); // pack must outlive me
27  ~EM();
28 
29  void setPitchSparsity(float sparsity) { m_pitchSparsity = sparsity; }
30  void setSourceSparsity(float sparsity) { m_sourceSparsity = sparsity; }
31 
32  int getBinCount() const { return m_binCount; }
33  int getNoteCount() const { return m_noteCount; }
34  int getSourceCount() const { return m_sourceCount; }
35  int getShiftCount() const { return m_shiftCount; }
36 
41  void iterate(const double *column);
42 
47  const float *getEstimate() const {
48  return m_estimate;
49  }
50 
55  const float *getPitchDistribution() const {
56  return m_pitches;
57  }
58 
64  const float *const *getSources() const {
65  return m_sources;
66  }
67 
73  const float *const *getShifts() const {
74  return m_shifts;
75  }
76 
77 private:
78  const InstrumentPack *m_pack;
79 
80  float *m_pitches;
81  float **m_shifts;
82  float **m_sources;
83 
84  float *m_updatePitches;
85  float **m_updateShifts;
86  float **m_updateSources;
87 
88  float *m_estimate;
89  float *m_q;
90 
91  const int m_noteCount;
92  const int m_shiftCount; // 1 + 2 * max template shift
93  const int m_binCount;
94  const int m_sourceCount;
95 
96  float m_pitchSparsity;
97  float m_shiftSparsity;
98  float m_sourceSparsity;
99 
100  void normaliseColumn(float *column, int size);
101  void normaliseGrid(float **grid, int size1, int size2);
102 
103  void expectation(const float *column); // size is m_binCount
104  void maximisation();
105 
106  const float *templateFor(int instrument, int note, int shift);
107  void rangeFor(int instrument, int &minPitch, int &maxPitch);
108  bool inRange(int instrument, int pitch);
109 };
110 
111 #endif
~EM()
Definition: EM.cpp:72
Definition: Instruments.h:32
int getShiftCount() const
Definition: EM.h:35
void iterate(const double *column)
Definition: EM.cpp:125
EM(const InstrumentPack *pack, bool useShifts)
Definition: EM.cpp:35
const float * getPitchDistribution() const
Definition: EM.h:55
int getNoteCount() const
Definition: EM.h:33
const float * getEstimate() const
Definition: EM.h:47
int getSourceCount() const
Definition: EM.h:34
int getBinCount() const
Definition: EM.h:32
const float *const * getShifts() const
Definition: EM.h:73
Definition: EM.h:23
const float *const * getSources() const
Definition: EM.h:64
void setSourceSparsity(float sparsity)
Definition: EM.h:30
void setPitchSparsity(float sparsity)
Definition: EM.h:29