Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
bowed_string.hpp
Go to the documentation of this file.
1// sbl/dsp/pm/bowed_string.hpp — A bowed string (AP-032 Phase 3; AP-041 Phase 4) (Physical modeling — widget)
2//
3// A StringBase played by a bow. The bow — a Bow<Law>, a BowSet, a
4// SwitchedExciter over two of them — is the app's and is handed in by
5// reference, with its own speed, weight and law; the load at the bridge is
6// the app's too. What this adds to the base is the name and the instrument's
7// words: a bowed string has a nut, a bridge and a body, and says so in its
8// own code. The wiring as compiled is a describe() away —
9// `sbl-diagram bowed-string [--body]` (AP-037).
10//
11// There is no envelope: a bow drawn at a steady speed makes a steady tone,
12// so the string is a drone by construction, and articulation is the bow
13// moving — or its pressure going to zero, which lifts it, and the string
14// rings free.
15//
16// Usage:
17// sbl::dsp::pm::BowSet bow;
18// bow.set_tables(sbl::dsp::pm::BOWS, 2); // pm/bow_tables.hpp
19// sbl::dsp::pm::ModalResonator<8> body;
20// body.set_modes(CELLO, 7);
21// sbl::dsp::pm::BowedString<sbl::dsp::pm::BowSet, sbl::dsp::pm::ModalResonator<8>> string(bow, body);
22// string.set_pitch_su(pitch);
23// bow.set_velocity_su(speed);
24// string.process(buf, n);
25
26#ifndef SBL_DSP_PM_BOWED_STRING_HPP_
27#define SBL_DSP_PM_BOWED_STRING_HPP_
28
29#include <cstdint>
30
32
33namespace sbl::dsp::pm {
34
35template<typename Bow, typename Body, uint16_t MaxPeriod = 1536>
36class BowedString : public StringBase<Bow, Body, MaxPeriod> {
38
39public:
40 BowedString(Bow& bow, Body& body) : Base(bow, body, "BowedString") {}
41
42 /// The body at the bridge, or the bare string with a rigid bridge.
43 void use_body(bool on) { Base::use_load(on); }
44 bool has_body() const { return Base::loaded(); }
45
46 /// Where the bow sits along the string (StringBase::set_position_su).
48
49 /// What is heard: 0 the body, 1 the bare string (StringBase::set_pickup_su).
50 void set_body_mix_su(float su) { Base::set_pickup_su(su); }
51
52 Bow& bow() { return Base::exciter(); }
53 Body& body() { return Base::load(); }
54};
55
56} // namespace sbl::dsp::pm
57
58#endif // SBL_DSP_PM_BOWED_STRING_HPP_
void set_body_mix_su(float su)
What is heard: 0 the body, 1 the bare string (StringBase::set_pickup_su).
BowedString(Bow &bow, Body &body)
void use_body(bool on)
The body at the bridge, or the bare string with a rigid bridge.
void set_bow_position_su(float su)
Where the bow sits along the string (StringBase::set_position_su).
void set_pickup_su(float su)
What is heard: 0 the load, 1 the bare string, a crossfade between.
void set_position_su(float su)
Where the exciter sits along the string.
Exciter & exciter()
The parts, for whoever owns them and for tools.
void use_load(bool on)
End b terminates on the load (true) or on a wall (false). The junction starts at rest.
Physical modeling: laws, bows, junctions, loads, resonators, strings (docs/conventions/physical-model...
Definition bow.hpp:31
What every string widget is made of (Physical modeling — widget base)