55
66#include < cstdint>
77
8+ #include " godot/engine.h"
89#include " godot_cpp/classes/node.hpp"
910#include " godot_cpp/classes/wrapped.hpp"
1011
1112namespace barely ::godot {
1213
14+ #define BARELY_GODOT_INSTRUMENT_CONTROLS (X ) \
15+ X (Gain, gain, float , 1 .0f ) \
16+ X (PitchShift, pitch_shift, float , 0 .0f ) \
17+ X (StereoPan, stereo_pan, float , 0 .0f ) \
18+ X (Attack, attack, float , 0 .05f ) \
19+ X (Decay, decay, float , 0 .0f ) \
20+ X (Sustain, sustain, float , 1 .0f ) \
21+ X (Release, release, float , 0 .1f ) \
22+ X (SliceMode, slice_mode, int , BarelySliceMode_kSustain) \
23+ X (OscMix, osc_mix, float , 1 .0f ) \
24+ X (OscMode, osc_mode, int , BarelyOscMode_kCrossfade) \
25+ X (OscNoiseMix, osc_noise_mix, float , 0 .0f ) \
26+ X (OscPitchShift, osc_pitch_shift, float , 0 .0f ) \
27+ X (OscShape, osc_shape, float , 0 .0f ) \
28+ X (OscSkew, osc_skew, float , 0 .0f ) \
29+ X (CrushDepth, crush_depth, float , 0 .0f ) \
30+ X (CrushRate, crush_rate, float , 0 .0f ) \
31+ X (DistortionMix, distortion_mix, float , 0 .0f ) \
32+ X (DistortionDrive, distortion_drive, float , 0 .0f ) \
33+ X (FilterCutoff, filter_cutoff, float , 1 .0f ) \
34+ X (FilterResonance, filter_resonance, float , 0 .5f ) \
35+ X (FilterTone, filter_tone, float , 0 .0f ) \
36+ X (DelaySend, delay_send, float , 0 .2f ) \
37+ X (ReverbSend, reverb_send, float , 0 .2f ) \
38+ X (SidechainSend, sidechain_send, float , 0 .0f ) \
39+ X (ArpMode, arp_mode, int , BarelyArpMode_kNone) \
40+ X (ArpGate, arp_gate, float , 0 .5f ) \
41+ X (ArpRate, arp_rate, float , 2 .0f ) \
42+ X (Retrigger, retrigger, bool , false ) \
43+ X (VoiceCount, voice_count, int , 8 )
44+
45+ #define BARELY_DECLARE_GODOT_INSTRUMENT_CONTROL (Name, name, type, default ) \
46+ private: \
47+ type name##_; \
48+ \
49+ public: \
50+ void set_##name(type name) { \
51+ name##_ = name; \
52+ BarelyInstrument_SetControl (BarelyEngine::get_singleton ()->get (), instrument_id_, \
53+ BarelyInstrumentControlType_k##Name, static_cast <float >(name##_)); \
54+ } \
55+ type get_##name() const { return name##_; }
56+
1357class BarelyInstrument : public ::godot::Node {
1458 public:
1559 ~BarelyInstrument ();
@@ -19,93 +63,6 @@ class BarelyInstrument : public ::godot::Node {
1963 void set_note_on (float pitch, float gain = 1 .0f , float pitch_shift = 0 .0f );
2064 bool is_note_on (float pitch) const ;
2165
22- void set_gain (float gain);
23- float get_gain () const { return gain_; }
24-
25- void set_pitch_shift (float pitch_shift);
26- float get_pitch_shift () const { return pitch_shift_; }
27-
28- void set_stereo_pan (float stereo_pan);
29- float get_stereo_pan () const { return stereo_pan_; }
30-
31- void set_attack (float attack);
32- float get_attack () const { return attack_; }
33-
34- void set_decay (float decay);
35- float get_decay () const { return decay_; }
36-
37- void set_sustain (float sustain);
38- float get_sustain () const { return sustain_; }
39-
40- void set_release (float release);
41- float get_release () const { return release_; }
42-
43- void set_slice_mode (int slice_mode);
44- int get_slice_mode () const { return slice_mode_; }
45-
46- void set_osc_mix (float osc_mix);
47- float get_osc_mix () const { return osc_mix_; }
48-
49- void set_osc_mode (int osc_mode);
50- int get_osc_mode () const { return osc_mode_; }
51-
52- void set_osc_noise_mix (float osc_noise_mix);
53- float get_osc_noise_mix () const { return osc_noise_mix_; }
54-
55- void set_osc_pitch_shift (float osc_pitch_shift);
56- float get_osc_pitch_shift () const { return osc_pitch_shift_; }
57-
58- void set_osc_shape (float osc_shape);
59- float get_osc_shape () const { return osc_shape_; }
60-
61- void set_osc_skew (float osc_skew);
62- float get_osc_skew () const { return osc_skew_; }
63-
64- void set_crush_depth (float crush_depth);
65- float get_crush_depth () const { return crush_depth_; }
66-
67- void set_crush_rate (float crush_rate);
68- float get_crush_rate () const { return crush_rate_; }
69-
70- void set_distortion_mix (float distortion_mix);
71- float get_distortion_mix () const { return distortion_mix_; }
72-
73- void set_distortion_drive (float distortion_drive);
74- float get_distortion_drive () const { return distortion_drive_; }
75-
76- void set_filter_cutoff (float filter_cutoff);
77- float get_filter_cutoff () const { return filter_cutoff_; }
78-
79- void set_filter_resonance (float filter_resonance);
80- float get_filter_resonance () const { return filter_resonance_; }
81-
82- void set_filter_tone (float filter_tone);
83- float get_filter_tone () const { return filter_tone_; }
84-
85- void set_delay_send (float delay_send);
86- float get_delay_send () const { return delay_send_; }
87-
88- void set_reverb_send (float reverb_send);
89- float get_reverb_send () const { return reverb_send_; }
90-
91- void set_sidechain_send (float sidechain_send);
92- float get_sidechain_send () const { return sidechain_send_; }
93-
94- void set_arp_mode (int arp_mode);
95- int get_arp_mode () const { return arp_mode_; }
96-
97- void set_arp_gate (float arp_gate);
98- float get_arp_gate () const { return arp_gate_; }
99-
100- void set_arp_rate (float arp_rate);
101- float get_arp_rate () const { return arp_rate_; }
102-
103- void set_retrigger (bool retrigger);
104- bool get_retrigger () const { return retrigger_; }
105-
106- void set_voice_count (int voice_count);
107- int get_voice_count () const { return voice_count_; }
108-
10966 void _ready () override ;
11067 void _process (double delta) override ;
11168
@@ -115,35 +72,7 @@ class BarelyInstrument : public ::godot::Node {
11572
11673 uint32_t instrument_id_ = 0 ;
11774
118- float gain_ = 1 .0f ;
119- float pitch_shift_ = 0 .0f ;
120- float stereo_pan_ = 0 .0f ;
121- float attack_ = 0 .0f ;
122- float decay_ = 0 .0f ;
123- float sustain_ = 1 .0f ;
124- float release_ = 0 .0f ;
125- int slice_mode_ = BarelySliceMode_kSustain;
126- float osc_mix_ = 1 .0f ;
127- int osc_mode_ = BarelyOscMode_kCrossfade;
128- float osc_noise_mix_ = 0 .0f ;
129- float osc_pitch_shift_ = 0 .0f ;
130- float osc_shape_ = 0 .0f ;
131- float osc_skew_ = 0 .0f ;
132- float crush_depth_ = 0 .0f ;
133- float crush_rate_ = 0 .0f ;
134- float distortion_mix_ = 0 .0f ;
135- float distortion_drive_ = 0 .0f ;
136- float filter_cutoff_ = 1 .0f ;
137- float filter_resonance_ = 0 .5f ;
138- float filter_tone_ = 0 .0f ;
139- float delay_send_ = 0 .0f ;
140- float reverb_send_ = 0 .0f ;
141- float sidechain_send_ = 0 .0f ;
142- int arp_mode_ = BarelyArpMode_kNone;
143- float arp_gate_ = 0 .5f ;
144- float arp_rate_ = 1 .0f ;
145- bool retrigger_ = false ;
146- int voice_count_ = 8 ;
75+ BARELY_GODOT_INSTRUMENT_CONTROLS (BARELY_DECLARE_GODOT_INSTRUMENT_CONTROL)
14776};
14877
14978} // namespace barely::godot
0 commit comments