MFCC.hpp
1 #pragma once
2 #include <Engine/Node/SimpleApi.hpp>
3 
4 #include <Analysis/GistState.hpp>
5 
6 #include <numeric>
7 namespace Analysis
8 {
9 struct Spectrum
10 {
12  {
13  static const constexpr auto prettyName = "Spectrum";
14  static const constexpr auto objectKey = "Mel";
15  static const constexpr auto category = "Analysis/Spectrum";
16  static const constexpr auto author = "ossia score, Gist library";
17  static const constexpr auto kind = Process::ProcessCategory::Analyzer;
18  static const constexpr auto description = "Get the magnitude spectrum of a signal";
19  static const constexpr auto tags = std::array<const char*, 0>{};
20  static const uuid_constexpr auto uuid
21  = make_uuid("422a1f92-821c-4073-ae50-e7c21487e27d");
22 
23  static const constexpr audio_in audio_ins[]{"in"};
24  static const constexpr audio_out audio_outs[]{"out"};
25  static const constexpr auto controls = tuplet::make_tuple(
26  Control::LogFloatSlider{"Gain", 0., 100., 1.},
27  Control::FloatSlider{"Gate", 0., 1., 0.});
28  };
29 
30  using State = GistState;
31  using control_policy = ossia::safe_nodes::last_tick;
32 
33  static void
34  run(const ossia::audio_port& in, float gain, float gate, ossia::audio_port& out,
35  ossia::token_request tk, ossia::exec_state_facade e, State& st)
36  {
37  st.processVector<&Gist<double>::getMagnitudeSpectrum>(in, gain, gate, out, tk, e);
38  }
39 };
40 
42 {
44  {
45  static const constexpr auto prettyName = "Mel spectrum";
46  static const constexpr auto objectKey = "Mel";
47  static const constexpr auto category = "Analysis/Spectrum";
48  static const constexpr auto author = "ossia score, Gist library";
49  static const constexpr auto kind = Process::ProcessCategory::Analyzer;
50  static const constexpr auto description
51  = "Get the Mel frequency spectrum of a signal";
52  static const constexpr auto tags = std::array<const char*, 0>{};
53  static const uuid_constexpr auto uuid
54  = make_uuid("f2b62e47-0e67-476f-b757-ef6a48610a78");
55 
56  static const constexpr audio_in audio_ins[]{"in"};
57  static const constexpr audio_out audio_outs[]{"out"};
58  static const constexpr auto controls = tuplet::make_tuple(
59  Control::LogFloatSlider{"Gain", 0., 100., 1.},
60  Control::FloatSlider{"Gate", 0., 1., 0.});
61  };
62 
63  using State = GistState;
64  using control_policy = ossia::safe_nodes::last_tick;
65 
66  static void
67  run(const ossia::audio_port& in, float gain, float gate, ossia::audio_port& out,
68  ossia::token_request tk, ossia::exec_state_facade e, State& st)
69  {
70  st.processVector<&Gist<double>::getMelFrequencySpectrum>(in, gain, gate, out, tk, e);
71  }
72 };
73 
74 struct MFCC
75 {
77  {
78  static const constexpr auto prettyName = "MFCC";
79  static const constexpr auto objectKey = "MFCC";
80  static const constexpr auto category = "Analysis/Spectrum";
81  static const constexpr auto author = "ossia score, Gist library";
82  static const constexpr auto kind = Process::ProcessCategory::Analyzer;
83  static const constexpr auto description
84  = "Get the mel-frequency cepstral coefficients of a signal";
85  static const constexpr auto tags = std::array<const char*, 0>{};
86  static const uuid_constexpr auto uuid
87  = make_uuid("26684acb-36f5-4a8b-8ed3-f32f9ffb436b");
88 
89  static const constexpr audio_in audio_ins[]{"in"};
90  static const constexpr audio_out audio_outs[]{"out"};
91  static const constexpr auto controls = tuplet::make_tuple(
92  Control::LogFloatSlider{"Gain", 0., 100., 1.},
93  Control::FloatSlider{"Gate", 0., 1., 0.});
94  };
95 
96  using State = GistState;
97  using control_policy = ossia::safe_nodes::last_tick;
98 
99  static void
100  run(const ossia::audio_port& in, float gain, float gate, ossia::audio_port& out,
101  ossia::token_request tk, ossia::exec_state_facade e, State& st)
102  {
103  st.processVector<&Gist<double>::getMelFrequencyCepstralCoefficients>(
104  in, gain, gate, out, tk, e);
105  }
106 };
107 }
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33
Definition: GistState.hpp:24
Definition: MFCC.hpp:77
Definition: MFCC.hpp:75
Definition: MFCC.hpp:44
Definition: MFCC.hpp:42
Definition: MFCC.hpp:12
Definition: MFCC.hpp:10
Definition: score-lib-process/Control/Widgets.hpp:77
Definition: SimpleApi.hpp:32