Skip to content

Commit

Permalink
example source formatting sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Place committed Dec 21, 2018
1 parent cb0094c commit 58b37ba
Show file tree
Hide file tree
Showing 28 changed files with 1,079 additions and 921 deletions.
1 change: 1 addition & 0 deletions source/projects/mc.min.info_tilde/mc.min.info_tilde.cpp
Expand Up @@ -7,6 +7,7 @@

using namespace c74::min;


class mc_info_tilde : public object<mc_info_tilde>, public mc_operator<> {
public:
MIN_DESCRIPTION { "Analyze a multi-channel signal. "
Expand Down
62 changes: 32 additions & 30 deletions source/projects/min.beat.pattern/min.beat.pattern.cpp
Expand Up @@ -10,61 +10,63 @@ using namespace c74::min;

class beat_pattern : public object<beat_pattern> {
public:
MIN_DESCRIPTION {"Bang at intervals in a repeating pattern."};
MIN_TAGS {"time"};
MIN_AUTHOR {"Cycling '74"};
MIN_RELATED {"min.beat.random, link.beat, metro, tempo, drunk"};
MIN_DESCRIPTION { "Bang at intervals in a repeating pattern." };
MIN_TAGS { "time" };
MIN_AUTHOR { "Cycling '74" };
MIN_RELATED { "min.beat.random, link.beat, metro, tempo, drunk" };

inlet<> input {this, "(toggle) on/off"};
outlet<> bang_out {this, "(bang) triggers at according to specified pattern"};
outlet<> interval_out {this, "(float) the interval for the current bang"};
inlet<> input { this, "(toggle) on/off" };
outlet<> bang_out { this, "(bang) triggers at according to specified pattern" };
outlet<> interval_out { this, "(float) the interval for the current bang" };

timer<> metro { this,
MIN_FUNCTION {
double interval = m_sequence[m_index];

timer<> metro {this, MIN_FUNCTION {
double interval = m_sequence[m_index];

interval_out.send(interval);
bang_out.send("bang");

metro.delay(interval);
interval_out.send(interval);
bang_out.send("bang");

m_index += 1;
metro.delay(interval);

if (m_index == m_sequence.size())
m_index = 0;
return {};
}};
m_index += 1;

if (m_index == m_sequence.size())
m_index = 0;
return {};
}
};

attribute<bool> on {this, "on", false, description {"Turn on/off the internal timer."},
attribute<bool> on {this, "on", false,
description {"Turn on/off the internal timer."},
setter { MIN_FUNCTION {
if (args[0] == true)
metro.delay(0.0); // fire the first one straight-away
else
metro.stop();
return args;
}}};
}}
};


message<> toggle {
this, "int", "Turn on/off the internal timer.", MIN_FUNCTION {
message<> toggle { this, "int", "Turn on/off the internal timer.",
MIN_FUNCTION {
on = args[0];
return {};
}};
}
};


message<> dictionary {this, "dictionary", "Use a dictionary to define the pattern of bangs produced.",
message<> dictionary { this, "dictionary", "Use a dictionary to define the pattern of bangs produced.",
MIN_FUNCTION {
dict d {args[0]};

m_sequence = d["pattern"];
return {};
}};

}
};

private:
int m_index {0};
atoms m_sequence {250.0, 250.0, 250.0, 250.0, 500.0, 500.0, 500.0, 500.0};
int m_index { 0 };
atoms m_sequence { 250.0, 250.0, 250.0, 250.0, 500.0, 500.0, 500.0, 500.0 };
};

MIN_EXTERNAL(beat_pattern);
85 changes: 50 additions & 35 deletions source/projects/min.beat.random/min.beat.random.cpp
Expand Up @@ -7,73 +7,88 @@

using namespace c74::min;


class beat_random : public object<beat_random> {
public:
MIN_DESCRIPTION {"Bang at random intervals."};
MIN_TAGS {"time"};
MIN_AUTHOR {"Cycling '74"};
MIN_RELATED {"min.beat.pattern, link.beat, metro, tempo, drunk"};

inlet<> input {this, "(toggle) on/off"};
outlet<> bang_out {this, "(bang) triggers at randomized interval"};
outlet<> interval_out {this, "(float) the interval for the current bang"};


argument<number> minimum_arg {this, "minimum", "Initial lower-bound of generated random interval.",
MIN_ARGUMENT_FUNCTION { min = arg; }};

argument<number> maximum_arg {this, "maximum", "Initial upper-bound of generated random interval.",
MIN_ARGUMENT_FUNCTION { max = arg; }};


timer<> metro {this, MIN_FUNCTION {
auto interval = lib::math::random(min, max);

interval_out.send(interval);
bang_out.send("bang");

metro.delay(interval);
return {};
}};
MIN_DESCRIPTION { "Bang at random intervals." };
MIN_TAGS { "time" };
MIN_AUTHOR { "Cycling '74" };
MIN_RELATED { "min.beat.pattern, link.beat, metro, tempo, drunk" };

inlet<> input { this, "(toggle) on/off" };
outlet<> bang_out { this, "(bang) triggers at randomized interval" };
outlet<> interval_out { this, "(float) the interval for the current bang" };

argument<number> minimum_arg { this, "minimum", "Initial lower-bound of generated random interval.",
MIN_ARGUMENT_FUNCTION {
min = arg;
}
};

argument<number> maximum_arg { this, "maximum", "Initial upper-bound of generated random interval.",
MIN_ARGUMENT_FUNCTION {
max = arg;
}
};

timer<> metro { this,
MIN_FUNCTION {
auto interval = lib::math::random(min, max);

interval_out.send(interval);
bang_out.send("bang");

metro.delay(interval);
return {};
}
};


attribute<number> min {this, "min", 250.0, title {"Minimum Interval"}, description {"Lower-bound of generated random interval."},
attribute<number> min { this, "min", 250.0, title {"Minimum Interval"},
description {"Lower-bound of generated random interval."},
setter { MIN_FUNCTION {
double value = args[0];

if (value < 1.0)
value = 1.0;
return {value};
}},
category {"Range"}, order {1}};
category {"Range"}, order {1}
};


attribute<number> max {this, "max", 1500.0, title {"Maximum Interval"}, description {"Upper-bound of generated random interval."},
attribute<number> max { this, "max", 1500.0, title {"Maximum Interval"},
description {"Upper-bound of generated random interval."},
setter { MIN_FUNCTION {
double value = args[0];

if (value < 1.0)
value = 1.0;
return {value};
}},
category {"Range"}, order {2}};
category {"Range"}, order {2}
};


attribute<bool> on {this, "on", false, title {"On/Off"}, description {"Activate the timer."},
attribute<bool> on { this, "on", false, title {"On/Off"},
description {"Activate the timer."},
setter { MIN_FUNCTION {
if (args[0] == true)
metro.delay(0.0); // fire the first one straight-away
else
metro.stop();
return args;
}}};
}}
};


message<> toggle {
this, "int", "Toggle the state of the timer.", MIN_FUNCTION {
message<> toggle { this, "int", "Toggle the state of the timer.",
MIN_FUNCTION {
on = args[0];
return {};
}};
}
};

};


Expand Down
45 changes: 25 additions & 20 deletions source/projects/min.buffer.index_tilde/min.buffer.index_tilde.cpp
Expand Up @@ -7,37 +7,42 @@

using namespace c74::min;


class buffer_index : public object<buffer_index>, public vector_operator<> {
public:
MIN_DESCRIPTION {"Read from a buffer~."};
MIN_TAGS {"audio, sampling"};
MIN_AUTHOR {"Cycling '74"};
MIN_RELATED {"index~, buffer~, wave~"};

inlet<> index_inlet {this, "(signal) Sample index"};
inlet<> channel_inlet {this, "(float) Audio channel to use from buffer~"};
outlet<> output {this, "(signal) Sample value at index", "signal"};
outlet<> changed {this, "(symbol) Notification that the content of the buffer~ changed."};

buffer_reference buffer {this,
MIN_FUNCTION { // will receive a symbol arg indicating
// 'binding', 'unbinding', or 'modified'
MIN_DESCRIPTION { "Read from a buffer~." };
MIN_TAGS { "audio, sampling" };
MIN_AUTHOR { "Cycling '74" };
MIN_RELATED { "index~, buffer~, wave~" };

inlet<> index_inlet { this, "(signal) Sample index" };
inlet<> channel_inlet { this, "(float) Audio channel to use from buffer~" };
outlet<> output { this, "(signal) Sample value at index", "signal" };
outlet<> changed { this, "(symbol) Notification that the content of the buffer~ changed." };

buffer_reference buffer { this,
MIN_FUNCTION { // will receive a symbol arg indicating 'binding', 'unbinding', or 'modified'
changed.send(args);
return {};
}};

}
};

argument<symbol> name_arg {this, "buffer-name", "Initial buffer~ from which to read.",
MIN_ARGUMENT_FUNCTION { buffer.set(arg); }};
MIN_ARGUMENT_FUNCTION {
buffer.set(arg);
}
};

argument<int> channel_arg {this, "channel", "Initial channel to read from the buffer~.",
MIN_ARGUMENT_FUNCTION { channel = arg; }};

MIN_ARGUMENT_FUNCTION {
channel = arg;
}
};

attribute<int, threadsafe::no, limit::clamp> channel {this, "channel", 1,
description {"Channel to read from the buffer~. The channel number uses 1-based counting."},
range {1, buffer_reference::k_max_channels}};

range {1, buffer_reference::k_max_channels}
};

void operator()(audio_bundle input, audio_bundle output) {
auto in = input.samples(0); // get vector for channel 0 (first channel)
Expand Down
62 changes: 37 additions & 25 deletions source/projects/min.buffer.loop_tilde/min.buffer.loop_tilde.cpp
Expand Up @@ -9,27 +9,34 @@ using namespace c74::min;

class buffer_loop : public object<buffer_loop>, public vector_operator<> {
public:
MIN_DESCRIPTION {"Read from a buffer~."};
MIN_TAGS {"audio, sampling"};
MIN_AUTHOR {"Cycling '74"};
MIN_RELATED {"index~, buffer~, wave~"};
MIN_DESCRIPTION { "Read from a buffer~." };
MIN_TAGS { "audio, sampling" };
MIN_AUTHOR { "Cycling '74" };
MIN_RELATED { "index~, buffer~, wave~" };

inlet<> index_inlet {this, "(signal) Sample index"};
inlet<> channel_inlet {this, "(float) Audio channel to use from buffer~"};
outlet<> output {this, "(signal) Sample value at index", "signal"};
outlet<> sync {this, "(signal) Sync", "signal"};

buffer_reference buffer {this, MIN_FUNCTION {
length.touch();
return {};
}};
inlet<> index_inlet { this, "(signal) Sample index" };
inlet<> channel_inlet { this, "(float) Audio channel to use from buffer~" };
outlet<> output { this, "(signal) Sample value at index", "signal" };
outlet<> sync { this, "(signal) Sync", "signal" };

buffer_reference buffer { this,
MIN_FUNCTION {
length.touch();
return {};
}
};

argument<symbol> name_arg {this, "buffer-name", "Initial buffer~ from which to read.",
MIN_ARGUMENT_FUNCTION { buffer.set(arg); }};
MIN_ARGUMENT_FUNCTION {
buffer.set(arg);
}
};

argument<int> channel_arg {this, "channel", "Initial channel to read from the buffer~.",
MIN_ARGUMENT_FUNCTION { channel = arg; }};
MIN_ARGUMENT_FUNCTION {
channel = arg;
}
};


attribute<int> channel {this, "channel", 1, description {"Channel to read from the buffer~."},
Expand All @@ -38,7 +45,8 @@ class buffer_loop : public object<buffer_loop>, public vector_operator<> {
if (n < 1)
n = 1;
return {n};
}}};
}}
};


attribute<number> length {this, "length", 1000.0, title {"Length (ms)"}, description {"Length of the buffer~ in milliseconds."},
Expand All @@ -55,7 +63,8 @@ class buffer_loop : public object<buffer_loop>, public vector_operator<> {
getter { MIN_GETTER_FUNCTION {
buffer_lock<false> b {buffer};
return {b.length_in_seconds() * 1000.0};
}}};
}}
};


attribute<number> speed {this, "speed", 1.0, description {"Playback speed of the loop"}};
Expand All @@ -68,13 +77,16 @@ class buffer_loop : public object<buffer_loop>, public vector_operator<> {
MIN_FUNCTION {
record = args[0];
return {};
}};
}
};


message<> dspsetup {this, "dspsetup", MIN_FUNCTION {
m_one_over_samplerate = 1.0 / samplerate();
return {};
}};
message<> dspsetup {this, "dspsetup",
MIN_FUNCTION {
m_one_over_samplerate = 1.0 / samplerate();
return {};
}
};


void operator()(audio_bundle input, audio_bundle output) {
Expand Down Expand Up @@ -123,9 +135,9 @@ class buffer_loop : public object<buffer_loop>, public vector_operator<> {
}

private:
double m_playback_position {0.0}; // normalized range
size_t m_record_position {0}; // native range
double m_one_over_samplerate {1.0};
double m_playback_position { 0.0 }; // normalized range
size_t m_record_position { 0 }; // native range
double m_one_over_samplerate { 1.0 };
};


Expand Down

0 comments on commit 58b37ba

Please sign in to comment.