Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Commit 0ffb11d

Browse files
committed
1 parent 1caef90 commit 0ffb11d

File tree

6 files changed

+120
-7
lines changed

6 files changed

+120
-7
lines changed

CsoundAC/Score.cpp

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ void Score::load(std::string filename)
172172
System::inform("Score::load.\n");
173173
}
174174

175+
void Score::load_filename(std::string filename)
176+
{
177+
load(filename);
178+
}
179+
175180
void Score::load(std::istream &stream)
176181
{
177182
Alg_seq seq(stream, true);
@@ -348,6 +353,11 @@ void Score::save(std::string filename)
348353
stream.close();
349354
}
350355

356+
void Score::save_filename(std::string filename)
357+
{
358+
save(filename);
359+
}
360+
351361
void Score::save(std::ostream &stream)
352362
{
353363
Alg_seq seq;
@@ -516,6 +526,11 @@ void Score::rescale(Event &event)
516526
}
517527
}
518528

529+
void Score::rescale_event(Event &event)
530+
{
531+
rescale(event);
532+
}
533+
519534
void Score::dump(std::ostream &stream)
520535
{
521536
stream << "silence::Score = " << int(size()) << " events:" << std::endl;
@@ -564,7 +579,7 @@ void Score::initialize(void)
564579
rescaleRanges[Event::HOMOGENEITY] = false;
565580
}
566581

567-
void Score::append_note(double time_, double duration, double status, double instrument, double key, double velocity, double phase, double pan, double depth, double height, double pitches) {
582+
void Score::append_note(double time_, double duration, double status, double instrument, double key, double velocity, double phase, double pan, double depth, double height, double pitches)
568583
{
569584
Event event;
570585
event.setTime(time_);
@@ -686,6 +701,13 @@ void Score::arrange(int oldInstrumentNumber, int newInstrumentNumber, double gai
686701
pans[oldInstrumentNumber] = pan;
687702
}
688703

704+
void Score::arrange_all(int oldInstrumentNumber, int newInstrumentNumber, double gain, double pan)
705+
{
706+
reassignments[oldInstrumentNumber] = newInstrumentNumber;
707+
gains[oldInstrumentNumber] = gain;
708+
pans[oldInstrumentNumber] = pan;
709+
}
710+
689711
void Score::removeArrangement()
690712
{
691713
reassignments.clear();
@@ -971,6 +993,18 @@ void Score::voicelead(size_t beginSource,
971993
System::inform("Score::voicelead.\n");
972994
}
973995

996+
void Score::voicelead_segments(size_t beginSource,
997+
size_t endSource,
998+
size_t beginTarget,
999+
size_t endTarget,
1000+
double lowest,
1001+
double range,
1002+
bool avoidParallelFifths,
1003+
size_t divisionsPerOctave_)
1004+
{
1005+
voicelead(beginSource, endSource, beginTarget, lowest, range, avoidParallelFifths, divisionsPerOctave_);
1006+
}
1007+
9741008
void Score::voicelead(size_t beginSource,
9751009
size_t endSource,
9761010
size_t beginTarget,
@@ -1065,6 +1099,20 @@ void Score::voicelead(size_t beginSource,
10651099
System::inform("Score::voicelead.\n");
10661100
}
10671101

1102+
void Score::voicelead_pitches(size_t beginSource,
1103+
size_t endSource,
1104+
size_t beginTarget,
1105+
size_t endTarget,
1106+
const std::vector<double> &target,
1107+
double lowest,
1108+
double range,
1109+
bool avoidParallelFifths,
1110+
size_t divisionsPerOctave_)
1111+
{
1112+
voicelead(beginSource, endSource, beginTarget, endTarget, target, lowest, range, avoidParallelFifths, divisionsPerOctave_);
1113+
}
1114+
1115+
10681116
void Score::setK(size_t priorBegin, size_t begin, size_t end, double base, double range)
10691117
{
10701118
std::vector<double> pitches = getPitches(priorBegin, begin);

CsoundAC/Score.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class SILENCE_PUBLIC Score :
7676
* Non-sounding data is ignored.
7777
*/
7878
virtual void load(std::string filename);
79+
virtual void load_filename(std::string filename);
7980
virtual void load(std::istream &stream);
8081
//virtual void load(MidiFile &midiFile);
8182
/**
@@ -85,6 +86,7 @@ class SILENCE_PUBLIC Score :
8586
* Only sounding data is saved.
8687
*/
8788
virtual void save(std::string filename);
89+
virtual void save_filename(std::string filename);
8890
/**
8991
* Save as a MIDI file, format 1.
9092
*/
@@ -98,6 +100,7 @@ class SILENCE_PUBLIC Score :
98100
virtual void findScale();
99101
virtual void rescale();
100102
virtual void rescale(Event &event);
103+
virtual void rescale_event(Event &event);
101104
/**
102105
* Sort all events in the score by time, instrument number, pitch, duration, loudness,
103106
* and other dimensions as given by Event::SORT_ORDER.
@@ -128,6 +131,7 @@ class SILENCE_PUBLIC Score :
128131
* Re-assign instrument number, adjust gain, and change pan for export to Csound score.
129132
*/
130133
virtual void arrange(int oldInstrumentNumber, int newInstrumentNumber, double gain, double pan);
134+
virtual void arrange_all(int oldInstrumentNumber, int newInstrumentNumber, double gain, double pan);
131135
/**
132136
* Remove instrument number, gain, and pan assignments.
133137
*/
@@ -232,6 +236,14 @@ class SILENCE_PUBLIC Score :
232236
double range,
233237
bool avoidParallelFifths,
234238
size_t divisionsPerOctave = 12);
239+
virtual void voicelead_segments(size_t beginSource,
240+
size_t endSource,
241+
size_t beginTarget,
242+
size_t endTarget,
243+
double lowest,
244+
double range,
245+
bool avoidParallelFifths,
246+
size_t divisionsPerOctave = 12);
235247
/**
236248
* Performs voice-leading between
237249
* the specified segments of the score
@@ -255,6 +267,15 @@ class SILENCE_PUBLIC Score :
255267
double range,
256268
bool avoidParallelFifths,
257269
size_t divisionsPerOctave = 12);
270+
virtual void voicelead_pitches(size_t beginSource,
271+
size_t endSource,
272+
size_t beginTarget,
273+
size_t endTarget,
274+
const std::vector<double> &targetPitches,
275+
double lowest,
276+
double range,
277+
bool avoidParallelFifths,
278+
size_t divisionsPerOctave = 12);
258279
/**
259280
* Return the index of the first event at or after the specified time,
260281
* that is, return "begin" for the time;

WebAssembly/CsoundAC/csoundac_embind.cpp

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ just above the class that appears in the same header file.
5656
5757
The order of definitions does not matter when compiling, so just keep these
5858
in the order describe above order.
59+
60+
In place of overloads use distinguished names, but for the Embind name, use
61+
the name that would go to the most commonly used overload.
5962
*/
6063

6164
EMSCRIPTEN_BINDINGS(csoundac) {
@@ -657,7 +660,6 @@ EMSCRIPTEN_BINDINGS(csoundac) {
657660
// FINISHED
658661
emscripten::class_<csound::MCRM, emscripten::base<csound::ScoreNode> >("MCRM")
659662
.constructor<>()
660-
.function("iterate", &csound::MCRM::iterate)
661663
.function("resize", &csound::MCRM::resize)
662664
.function("setDepth", &csound::MCRM::setDepth)
663665
.function("setTransformationElement", &csound::MCRM::setTransformationElement)
@@ -693,7 +695,8 @@ EMSCRIPTEN_BINDINGS(csoundac) {
693695
// FINISHED
694696
emscripten::class_<csound::Rescale, emscripten::base<csound::Node> >("Rescale")
695697
.constructor<>()
696-
.function("getRescale", &csound::Rescale::getRescale)
698+
// NOT SUPPORTED
699+
// .function("getRescale", &csound::Rescale::getRescale, emscripten::allow_raw_pointers())
697700
.function("initialize", &csound::Rescale::initialize)
698701
.function("setRescale", &csound::Rescale::setRescale)
699702
;
@@ -719,8 +722,49 @@ EMSCRIPTEN_BINDINGS(csoundac) {
719722
;
720723
emscripten::class_<csound::Score>("Score")
721724
.constructor<>()
722-
.function("chord", &csound::Score::chord)
723-
;
725+
.function("append_note", &csound::Score::append_note)
726+
.function("append_event", &csound::Score::append_event)
727+
.function("arrange_all", &csound::Score::arrange_all)
728+
.function("getCsoundScore", &csound::Score::getCsoundScore)
729+
.function("getDuration", &csound::Score::getDuration)
730+
.function("getPitches", &csound::Score::getPitches)
731+
.function("getPT", &csound::Score::getPT)
732+
.function("getPTV", &csound::Score::getPTV)
733+
// NOT SUPPORTED
734+
// .function("getScale", &csound::Score::getScale, emscripten::allow_raw_pointers())
735+
.function("getPTV", &csound::Score::getPTV)
736+
.function("getVoicing", &csound::Score::getVoicing)
737+
.function("indexAfterTime", &csound::Score::indexAfterTime)
738+
.function("indexAtTime", &csound::Score::indexAtTime)
739+
.function("indexToTime", &csound::Score::indexToTime)
740+
.function("initialize", &csound::Score::initialize)
741+
.function("load", &csound::Score::load_filename)
742+
.function("process", &csound::Score::process)
743+
.function("remove", &csound::Score::remove)
744+
.function("removeArrangement", &csound::Score::removeArrangement)
745+
.function("rescale", emscripten::select_overload<void()>(&csound::Score::rescale))
746+
.function("save", &csound::Score::save_filename)
747+
.function("setDuration", &csound::Score::setDuration)
748+
.function("setK", &csound::Score::setK)
749+
.function("setKL", &csound::Score::setKL)
750+
.function("setKV", &csound::Score::setKV)
751+
.function("setPitchClassSet", &csound::Score::setPitchClassSet)
752+
.function("setPitches", &csound::Score::setPitches)
753+
.function("setPT", &csound::Score::setPT)
754+
.function("setPTV", &csound::Score::setPTV)
755+
.function("setQ", &csound::Score::setQ)
756+
.function("setQL", &csound::Score::setQL)
757+
.function("setQV", &csound::Score::setQV)
758+
.function("setScale", &csound::Score::setScale)
759+
.function("setVoicing", &csound::Score::setVoicing)
760+
.function("sort", &csound::Score::sort)
761+
.function("temper", &csound::Score::temper)
762+
.function("tieOverlappingNotes", &csound::Score::tieOverlappingNotes)
763+
.function("toString", &csound::Score::toString)
764+
.function("voicelead", &csound::Score::voicelead_segments)
765+
.function("voicelead_pitches", &csound::Score::voicelead_pitches)
766+
.function("setPTV", &csound::Score::setPTV)
767+
;
724768
// FINISHED
725769
emscripten::class_<csound::ScoreNode, emscripten::base<csound::Node> >("ScoreNode")
726770
.constructor<>()

WebAssembly/examples/CsoundAudioProcessor.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/CsoundAudioProcessor.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/CsoundAudioProcessor.wasm

536 KB
Binary file not shown.

0 commit comments

Comments
 (0)