Skip to content

Commit

Permalink
Tidy: apply clang-format globally
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed Aug 11, 2024
1 parent f2de83c commit 84d0af4
Show file tree
Hide file tree
Showing 165 changed files with 1,018 additions and 738 deletions.
23 changes: 13 additions & 10 deletions src/core/actions/actionRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ void ActionRecorder::updateBpm(float ratio, int quantizerStep)
if (ratio == 1.0f)
return;

m_model.get().actions.updateKeyFrames([=](Frame old) {
/* The division here cannot be precise. A new frame can be 44099 and the
quantizer set to 44100. That would mean two recs completely useless. So we
compute a reject value ('delta'): if it's lower than 6 frames the new frame
m_model.get().actions.updateKeyFrames([=](Frame old)
{
/* The division here cannot be precise. A new frame can be 44099 and the
quantizer set to 44100. That would mean two recs completely useless. So we
compute a reject value ('delta'): if it's lower than 6 frames the new frame
is collapsed with a quantized frame. FIXME - maybe 6 frames are too low. */
Frame frame = static_cast<Frame>(old * ratio);
if (frame != 0)
Expand All @@ -111,7 +112,8 @@ void ActionRecorder::updateSamplerate(int systemRate, int patchRate)

float ratio = systemRate / (float)patchRate;

m_model.get().actions.updateKeyFrames([=](Frame old) { return floorf(old * ratio); });
m_model.get().actions.updateKeyFrames([=](Frame old)
{ return floorf(old * ratio); });
m_model.swap(model::SwapType::NONE);
}

Expand All @@ -123,7 +125,8 @@ bool ActionRecorder::cloneActions(ID channelId, ID newChannelId)
std::vector<Action> actions;
std::unordered_map<ID, ID> map; // Action ID mapper, old -> new

m_model.get().actions.forEachAction([&](const Action& a) {
m_model.get().actions.forEachAction([&](const Action& a)
{
if (a.channelId != channelId)
return;

Expand Down Expand Up @@ -374,7 +377,7 @@ std::unordered_set<ID> ActionRecorder::consolidate()
void ActionRecorder::clearAllActions()
{
m_model.get().tracks.forEachChannel([](Channel& ch)
{ ch.hasActions = false; return true; });
{ ch.hasActions = false; return true; });
m_model.get().actions.clearAll();
m_model.swap(model::SwapType::HARD);
}
Expand Down Expand Up @@ -413,9 +416,9 @@ bool ActionRecorder::isSinglePressMode(ID channelId) const

void ActionRecorder::consolidate(const Action& a1, std::size_t i)
{
/* This algorithm must start searching from the element next to 'a1': since
live actions are recorded in linear sequence, the potential partner of 'a1'
always lies beyond a1 itself. Without this trick (i.e. if it loops from
/* This algorithm must start searching from the element next to 'a1': since
live actions are recorded in linear sequence, the potential partner of 'a1'
always lies beyond a1 itself. Without this trick (i.e. if it loops from
vector.begin() each time) the algorithm would end up matching wrong partners. */

for (auto it = m_liveActions.begin() + i; it != m_liveActions.end(); ++it)
Expand Down
26 changes: 13 additions & 13 deletions src/core/actions/actionRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ class ActionRecorder
void reset();

/* updateBpm
Changes actions position by calculating the new bpm value. */
Changes actions position by calculating the new bpm value. */

void updateBpm(float ratio, int quantizerStep);

/* updateSamplerate
Changes actions position by taking in account the new samplerate. If
f_system == f_patch nothing will change, otherwise the conversion is
mandatory. */
Changes actions position by taking in account the new samplerate. If
f_system == f_patch nothing will change, otherwise the conversion is
mandatory. */

void updateSamplerate(int systemRate, int patchRate);

/* cloneActions
Clones actions in channel 'channelId', giving them a new channel ID. Returns
whether any action has been cloned. */
Clones actions in channel 'channelId', giving them a new channel ID. Returns
whether any action has been cloned. */

bool cloneActions(ID channelId, ID newChannelId);

/* liveRec
Records a user-generated action. NOTE_ON or NOTE_OFF only for now. */
Records a user-generated action. NOTE_ON or NOTE_OFF only for now. */

void liveRec(ID channelId, MidiEvent e, Frame global);

Expand Down Expand Up @@ -100,13 +100,13 @@ class ActionRecorder
void updateVelocity(const Action&, float value);

/* consolidate
Records all live actions. Returns a set of channels IDs that have been
recorded. */
Records all live actions. Returns a set of channels IDs that have been
recorded. */

std::unordered_set<ID> consolidate();

/* clearAllActions
Deletes all recorded actions. */
Deletes all recorded actions. */

void clearAllActions();

Expand All @@ -126,7 +126,7 @@ class ActionRecorder

private:
/* areComposite
Composite: NOTE_ON + NOTE_OFF on the same note. */
Composite: NOTE_ON + NOTE_OFF on the same note. */

bool areComposite(const Action& a1, const Action& a2) const;

Expand All @@ -145,8 +145,8 @@ class ActionRecorder
void recordNonFirstEnvelopeAction(ID channelId, Frame frame, int value);
#endif
/* consolidate
Given an action 'a1' tries to find the matching NOTE_OFF and updates the
action accordingly. */
Given an action 'a1' tries to find the matching NOTE_OFF and updates the
action accordingly. */

void consolidate(const Action& a1, std::size_t i);

Expand Down
2 changes: 1 addition & 1 deletion src/core/api/storageApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class StorageApi
std::function<void(float)> progress) const;

/* loadProject
Loads a new project. Returns a model::LoadState object containing the
Loads a new project. Returns a model::LoadState object containing the
operation state. */

model::LoadState loadProject(const std::string& projectPath, std::function<void(float)> progress);
Expand Down
2 changes: 1 addition & 1 deletion src/core/channels/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Channel final
bool canSendMidi() const;

/* isAudible
True if this channel is currently audible: not muted or not included in a
True if this channel is currently audible: not muted or not included in a
solo session. */

bool isAudible(bool mixerHasSolos) const;
Expand Down
4 changes: 2 additions & 2 deletions src/core/channels/channelFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct Data
};

/* getNextId
Returns the next channel ID that will be assigned to a new channel. */
Returns the next channel ID that will be assigned to a new channel. */

ID getNextId();

Expand All @@ -57,7 +57,7 @@ ID getNextId();
void reset();

/* create (1)
Creates a new channel. If channelId == 0 generates a new ID, reuse the one
Creates a new channel. If channelId == 0 generates a new ID, reuse the one
passed in otherwise. */

Data create(ID channelId, ChannelType type, int bufferSize, Resampler::Quality, bool overdubProtection);
Expand Down
11 changes: 7 additions & 4 deletions src/core/channels/channelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void ChannelManager::loadSampleChannel(ID channelId, Wave& wave)
loadSampleChannel(channel, &newWave);
m_model.swap(model::SwapType::HARD);

/* Remove the old Wave, if any. It is safe to do it now: the audio thread is
/* Remove the old Wave, if any. It is safe to do it now: the audio thread is
already processing the new Document. */

if (oldWave != nullptr)
Expand Down Expand Up @@ -563,16 +563,19 @@ void ChannelManager::setupChannelCallbacks(const Channel& ch, ChannelShared& sha
{
assert(onChannelPlayStatusChanged != nullptr);

shared.playStatus.onChange = [this, id = ch.id](ChannelStatus status) {
shared.playStatus.onChange = [this, id = ch.id](ChannelStatus status)
{
onChannelPlayStatusChanged(id, status);
};

if (ch.type == ChannelType ::SAMPLE)
{
shared.quantizer->schedule(Q_ACTION_PLAY + ch.id, [&shared](Frame delta) {
shared.quantizer->schedule(Q_ACTION_PLAY + ch.id, [&shared](Frame delta)
{
rendering::playSampleChannel(shared, delta);
});
shared.quantizer->schedule(Q_ACTION_REWIND + ch.id, [&shared](Frame delta) {
shared.quantizer->schedule(Q_ACTION_REWIND + ch.id, [&shared](Frame delta)
{
const ChannelStatus status = shared.playStatus.load();
if (status == ChannelStatus::OFF)
rendering::playSampleChannel(shared, delta);
Expand Down
26 changes: 13 additions & 13 deletions src/core/channels/channelManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ class ChannelManager final
Channel& getChannel(ID);

/* hasInputRecordableChannels
Tells whether Mixer has one or more input-recordable channels. */
Tells whether Mixer has one or more input-recordable channels. */

bool hasInputRecordableChannels() const;

/* hasActions
True if at least one Channel has actions recorded in it. */
True if at least one Channel has actions recorded in it. */

bool hasActions() const;

/* hasAudioData
True if at least one Sample Channel has some audio recorded in it. */
True if at least one Sample Channel has some audio recorded in it. */

bool hasAudioData() const;

Expand All @@ -97,7 +97,7 @@ class ChannelManager final

/* reset
Brings channels configuration back to the initial state: two I/O master
channels, one preview channel. */
channels, one preview channel. */

void reset(Frame framesInBuffer);

Expand All @@ -121,22 +121,22 @@ class ChannelManager final
void setTrackWidth(std::size_t trackIndex, int width);

/* addChannel
Adds a new channel to the stack. */
Adds a new channel to the stack. */

Channel& addChannel(ChannelType, std::size_t trackIndex, int bufferSize);

/* loadSampleChannel (1)
Creates a new Wave from a file path and loads it inside a Sample Channel. */
Creates a new Wave from a file path and loads it inside a Sample Channel. */

int loadSampleChannel(ID channelId, const std::string&, int sampleRate, Resampler::Quality);

/* loadSampleChannel (2)
Loads an existing Wave inside a Sample Channel. */
Loads an existing Wave inside a Sample Channel. */

void loadSampleChannel(ID channelId, Wave&);

/* freeChannel
Unloads existing Wave from a Sample Channel. */
Unloads existing Wave from a Sample Channel. */

void freeSampleChannel(ID channelId);
void freeAllSampleChannels();
Expand All @@ -151,8 +151,8 @@ class ChannelManager final
Channel& cloneChannel(ID channelId, int bufferSize, const std::vector<Plugin*>&);

/* finalizeInputRec
Fills armed Sample channel with audio data coming from an input recording
session. */
Fills armed Sample channel with audio data coming from an input recording
session. */

void finalizeInputRec(const mcl::AudioBuffer&, Frame recordedFrames, Frame currentFrame);

Expand All @@ -173,7 +173,7 @@ class ChannelManager final

/* consolidateChannels
Enable reading actions for Channels that have just been filled with actions
after an action recording session. This will start reading actions right
after an action recording session. This will start reading actions right
away, without checking whether conf::treatRecsAsLoops is enabled or not.
Same thing for MIDI channels. */

Expand All @@ -200,7 +200,7 @@ class ChannelManager final
void loadSampleChannel(Channel&, Wave*, Frame begin = -1, Frame end = -1, Frame shift = -1) const;

/* setupChannelCallbacks
Prepares the channel with the necessary callbacks. Call this whenever a
Prepares the channel with the necessary callbacks. Call this whenever a
new channel is created. */

void setupChannelCallbacks(const Channel&, ChannelShared&) const;
Expand All @@ -209,7 +209,7 @@ class ChannelManager final
std::vector<Channel*> getOverdubbableChannels();

/* setupChannelPostRecording
Fnialize the Sample channel after an audio recording session. */
Fnialize the Sample channel after an audio recording session. */

void setupChannelPostRecording(Channel&, Frame currentFrame);

Expand Down
6 changes: 3 additions & 3 deletions src/core/channels/channelShared.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct ChannelShared final

bool isReadingActions() const;

/* setBufferSize
/* setBufferSize
Sets a new size for the internal audio buffer. */

void setBufferSize(int);
Expand All @@ -68,14 +68,14 @@ struct ChannelShared final
std::optional<Quantizer> quantizer;

/* Optional render queue for sample-based channels. Used by callers on thread
different than the real-time one to instruct the real-time one how to render
different than the real-time one to instruct the real-time one how to render
audio. */

std::optional<RenderQueue> renderQueue = {};

/* Optional resampler for sample-based channels. Unfortunately a Resampler
object (based on libsamplerate) doesn't like to get copied while rendering
audio, so can't live inside a Channel object (which is copied on model
audio, so can't live inside a Channel object (which is copied on model
changes by the Swapper mechanism). Let's put it in the shared state here. */

std::optional<Resampler> resampler = {};
Expand Down
4 changes: 2 additions & 2 deletions src/core/channels/midiChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class MidiChannel final
MidiChannel(const Patch::Channel&);

/* outputEnabled
Tells whether MIDI output is enabled or not. */
Tells whether MIDI output is enabled or not. */

bool outputEnabled;

/* outputFilter
Which MIDI channel data should be sent to. */
Which MIDI channel data should be sent to. */

int outputFilter;
};
Expand Down
8 changes: 4 additions & 4 deletions src/core/channels/midiInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ class MidiInput final
MidiInput(const Patch::Channel&);

/* isAllowed
Tells whether the MIDI channel 'c' is enabled to receive MIDI data. */
Tells whether the MIDI channel 'c' is enabled to receive MIDI data. */

bool isAllowed(int c) const;

/* enabled
Tells whether MIDI learning is enabled for the current channel. */
Tells whether MIDI learning is enabled for the current channel. */

bool enabled;

/* filter
Which MIDI channel should be filtered out when receiving MIDI messages.
If -1 means 'all'. */
Which MIDI channel should be filtered out when receiving MIDI messages.
If -1 means 'all'. */

int filter;

Expand Down
2 changes: 1 addition & 1 deletion src/core/channels/midiLightning.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MidiLightning final
MidiLightning(const Patch::Channel&);

/* enabled
Tells whether MIDI lighting is enabled or not. */
Tells whether MIDI lighting is enabled or not. */

bool enabled;

Expand Down
2 changes: 1 addition & 1 deletion src/core/channels/sampleChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SampleChannel final
Wave* getWave() const;

/* loadWave
Loads Wave and sets it up (name, markers, ...). Resets begin/end points
Loads Wave and sets it up (name, markers, ...). Resets begin/end points
and shift if not specified. */

void loadWave(Wave*, Frame begin = -1, Frame end = -1, Frame shift = -1);
Expand Down
4 changes: 2 additions & 2 deletions src/core/confFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

namespace giada::m::confFactory
{
/* serialize
/* serialize
Writes Conf to disk. */

bool serialize(const Conf&);

/* deserialize
/* deserialize
Reads data from disk into a new Conf object. */

Conf deserialize();
Expand Down
Loading

0 comments on commit 84d0af4

Please sign in to comment.