Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ loopercat_core_test(sysex_tests)
loopercat_core_test(storage_register_tests)
loopercat_core_test(catalog_tests)
loopercat_core_test(commands_tests)
# Push on the two-track model: into a memory with no take on any track, nowhere else.
loopercat_core_test(rc500_push_tests)
# Play Count-In on the two-track model: the RHYTHM triple with the RC-5's numbers (2026-11-07).
loopercat_core_test(rc500_count_in_tests)
# A card as a folder on disk (#77): the factory pair, export by restore, import by the scan.
loopercat_core_test(card_folder_tests)
loopercat_core_test(slot_story_tests)
Expand Down
7 changes: 4 additions & 3 deletions app/CardPermissions.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ struct CardPermissions {
bool downmix = false;
// The one short sentence a closed control says on a card whose model has
// some operations open and others not ("On the RC-500, LooperCat does
// rename, set one-shot, pull, clear and restore only"), or, on a model this app only
// reads, what it writes to. Empty when every operation is open, and when
// no card the table knows is in front of the app.
// rename, set one-shot, set count-in, push, pull, clear and restore
// only"), or, on a model this app only reads, what it writes to. Empty
// when every operation is open, and when no card the table knows is in
// front of the app.
std::string closed;

bool anyWrite() const
Expand Down
18 changes: 14 additions & 4 deletions app/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,10 @@ MainComponent::MainComponent(std::string explicitVolume, juce::File dataOverride
} }));
};
table.onAudioDropped = [this](int slot, juce::String path) {
// Occupied on any track: the one-track model replaces, the two-track
// model is refused by the core in its own words (catalog::uploadOffered).
if (const SlotRow* row = pedalBusy ? nullptr : slotRowFor(slot))
pushWav(slot, path, row->info.hasAudio);
pushWav(slot, path, catalog::holdsAudio(row->info));
};
table.onSwapRequested = [this](int from, int to) {
if (pedalBusy || slotRowFor(from) == nullptr || slotRowFor(to) == nullptr)
Expand Down Expand Up @@ -2096,10 +2098,18 @@ void MainComponent::showSlotMenu(int slot, juce::Point<int> screenPosition)
// panel now (and the two lamp columns still flip on click), so this menu
// stopped being a second copy of them.
juce::PopupMenu menu;
// A replace is the one-track model's; a two-track memory with a take on
// any track, or a file in either folder, is not offered an upload
// (offersUpload) - and since push is open on the model, the greyed item
// says why itself: the "closed" sentence is for closed operations.
const bool offered = offersUpload(row);
menu.addItem(3,
occupied ? juce::String::fromUTF8("Replace audio\xe2\x80\xa6")
: juce::String::fromUTF8("Push audio here\xe2\x80\xa6"),
can.push);
!occupied && row.wavFile.empty()
? juce::String::fromUTF8("Push audio here\xe2\x80\xa6")
: offered ? juce::String::fromUTF8("Replace audio\xe2\x80\xa6")
: juce::String::fromUTF8("Replace audio\xe2\x80\xa6 (not offered on a used ")
+ utf8(snapshot.family) + " memory yet)",
can.push && offered);
menu.addItem(4, juce::String::fromUTF8("Pull to folder\xe2\x80\xa6"), can.pull && occupied);
juce::PopupMenu downmix;
downmix.addItem(6, juce::String::fromUTF8("Both outputs\xe2\x80\xa6"));
Expand Down
12 changes: 12 additions & 0 deletions app/PedalWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ struct SlotRow
bool operator==(const SlotRow&) const = default;
};

// Whether the row's memory is offered an upload: the config's say
// (catalog::uploadOffered) and the folders' as the scan listed them. The core
// refuses a two-track memory with a take on either track, configured or
// merely in its folder (commands::push); the menu, the drag's highlight, the
// drop and the empty-slot hint all ask this, so the player is not offered a
// push the core refuses. On the one-track model every row is offered one:
// an occupied slot takes a replace.
inline bool offersUpload(const SlotRow& row)
{
return catalog::uploadOffered(row.info) && (row.info.tracks.size() <= 1 || row.wavFile.empty());
}

struct PedalSnapshot
{
std::string volume; // mount path; empty = no pedal found
Expand Down
28 changes: 21 additions & 7 deletions app/SlotTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <felitronics/appkit/Brand.h>

#include <loopercat/Catalog.hpp>
#include <loopercat/Wav.hpp>

#include <cmath>
Expand Down Expand Up @@ -379,10 +380,11 @@ void SlotTable::cellClicked(int row, int columnId, const juce::MouseEvent& e)
onCountInToggled(slotOfRow(row));
return;
}
// The empty-slot hint is a button: click opens the WAV chooser.
// The empty-slot hint is a button: click opens the WAV chooser. Empty on
// every track, the second alone counts (catalog::holdsAudio).
if (columnId == kWavFile && onEmptyWavCellClicked && slotOfRow(row) > 0 && allowed().push) {
const SlotRow& r = rows_[static_cast<std::size_t>(row)];
if (!r.info.hasAudio && r.wavFile.empty())
if (!catalog::holdsAudio(r.info) && r.wavFile.empty())
onEmptyWavCellClicked(r.info.slot);
}
}
Expand Down Expand Up @@ -453,11 +455,22 @@ bool SlotTable::isInterestedInFileDrag(const juce::StringArray& files)
return false;
}

// A row takes a file when its memory is offered an upload (offersUpload,
// PedalWorker.h): every row of a one-track model, a memory of a two-track one
// with nothing on either track — the highlight under the drag, the drop and
// the empty-slot hint agree on it.
bool SlotTable::takesAudio(int row) const
{
return row >= 0 && static_cast<std::size_t>(row) < rows_.size()
&& offersUpload(rows_[static_cast<std::size_t>(row)]);
}

void SlotTable::fileDragMove(const juce::StringArray&, int x, int y)
{
const int row = rowAt(x, y);
if (row != dragRow_) {
dragRow_ = row;
const int target = takesAudio(row) ? row : -1;
if (target != dragRow_) {
dragRow_ = target;
table_.repaint();
}
}
Expand All @@ -473,7 +486,7 @@ void SlotTable::filesDropped(const juce::StringArray& files, int x, int y)
const int row = rowAt(x, y);
dragRow_ = -1;
table_.repaint();
if (slotOfRow(row) <= 0 || !onAudioDropped || !allowed().push)
if (slotOfRow(row) <= 0 || !onAudioDropped || !allowed().push || !takesAudio(row))
return;
for (const auto& file : files)
if (isImportableAudio(file)) {
Expand Down Expand Up @@ -587,8 +600,9 @@ void SlotTable::paintCell(juce::Graphics& g, int row, int columnId, int width, i
case kLufs: break; // drawn from the loudness cells below
case kWavFile:
// The empty-slot hint invites a push; a card this app only reads
// gets no invitation.
text = r.wavFile.empty() && !loaded
// gets no invitation, and neither does a memory with a take on any
// track - the second alone counts (catalog::holdsAudio).
text = r.wavFile.empty() && !catalog::holdsAudio(r.info)
? (allowed().push
? juce::String::fromUTF8("\xe2\x80\x94 drop audio here, or click to choose")
: juce::String())
Expand Down
1 change: 1 addition & 0 deletions app/SlotTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class SlotTable final : public juce::Component,
void updateSwapTarget();

CardPermissions allowed() const { return permissions ? permissions() : CardPermissions {}; }
bool takesAudio(int row) const; // the row's memory is offered an upload (catalog::uploadOffered)
int rowAt(int x, int y);
int rowOfSlot(int slot) const;
int slotOfRow(int rowIndex) const; // 0 when out of range
Expand Down
12 changes: 12 additions & 0 deletions core/include/loopercat/Catalog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ inline bool holdsAudio(const SlotInfo& info)
[](const TrackInfo& track) { return track.hasAudio; });
}

// Whether the config offers an upload into a memory, as push decides it
// (Commands.hpp): on a one-track model always — an occupied slot takes a
// replace — and on a model with more tracks only while no track holds a
// take, because what the pedal makes of a second take of another length
// beside a pushed first one has not been asked of it. The config's half:
// push looks into the track folders too, and so does the app before it
// offers one (offersUpload, PedalWorker.h), with the folders the scan read.
inline bool uploadOffered(const SlotInfo& info)
{
return info.tracks.size() <= 1 || !holdsAudio(info);
}

// One track's facts, read from its own section (rc0::sectionField). A memory
// that lacks a section its model promises is refused by name, not read as
// empty.
Expand Down
46 changes: 42 additions & 4 deletions core/include/loopercat/Commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,38 @@ inline PushResult push(const fs::path& volume, const fs::path& wavPath, int slot
if (options.landedName)
assertLandedName(*options.landedName);

// The gate, on every path: a drop-only push lands a file on the card as
// a configured one does, so the same profile refuses it, before a byte
// moves — and the memory it lands in is read for the rule below, config
// written or not.
const std::string memoryText = readMemoryFor(volume, profile::Operation::push);
const profile::DeviceProfile& family = rc0::profileOf(memoryText);
std::string body = rc0::slotBody(memoryText, slot);

// A memory of a model with more tracks than one takes an upload only
// while no track holds a take — configured or merely in its folder — and
// force does not change that. The take lands on track 1 as the memory's
// first recording; what the pedal makes of a second take of another
// length beside it has not been asked of it (hardware reading 2026-09-23:
// a track 2 recorded after track 1 came out exactly half its length; a
// non-multiple length is unknown), so until it has, a used memory is not
// offered, and the refusal names the track that is in the way (decided
// 2026-10-29). The one-track model keeps its replace below.
if (family.trackCount > 1)
for (int track = 1; track <= family.trackCount; ++track) {
const bool configured =
rc0::sectionField(body, rc0::trackSectionName(track), "WavStat") == 1;
if (configured || !volume::listTrackWavs(volume, family, slot, track).empty())
throw Error("push refused: memory " + std::to_string(slot) + " holds a take on track "
+ std::to_string(track) + " - upload into a used \""
+ std::string(family.familyName) + "\" memory is not offered yet");
}

std::optional<params::SlotParams> slotParams;
std::string newDocument;
bool noteLengthReplaced = false;
if (options.writeConfig) {
slotParams = params::computeSlotParams(info.frames);
const std::string memoryText = readMemoryFor(volume, profile::Operation::push);
std::string body = rc0::slotBody(memoryText, slot);
// The new take defines a new length, so the field becomes a bar count.
// If it was a note value, that mode is gone — reported, never silent.
// Only a memory that HOLDS a loop can have a length to replace: a
Expand All @@ -717,6 +742,16 @@ inline PushResult push(const fs::path& volume, const fs::path& wavPath, int slot
slotParams->measureField());
body = rc0::setSectionField(body, rc0::kSectionTrack1, "RecTmp", slotParams->tempoTenths);
body = rc0::setSectionField(body, rc0::kSectionMaster, "Tempo", slotParams->tempoTenths);
// LpLen is the length of the memory's first recording, on the
// two-track model too (hardware reading 2026-09-23: a memory recorded
// track 1 first at 8 bars then track 2 at 4 carries LpLen 8; one
// recorded on track 2 alone carries that track's length). Into an
// empty memory the pushed take is that recording. The two-track
// model's MASTER also carries CurrentTrack and LpMod, and neither is
// written: single-track recordings off the pedal (2026-09-22) carry
// CurrentTrack 0, the factory value an empty memory already holds,
// and LpMod 0 on one such memory and 1 on another, so it is not the
// recording's doing — what it is remains a checkpoint question.
body = rc0::setSectionField(body, rc0::kSectionMaster, "LpLen", slotParams->measures);
if (options.oneShot)
body = rc0::setSectionField(body, rc0::kSectionTrack1, "One", 1);
Expand All @@ -725,7 +760,10 @@ inline PushResult push(const fs::path& volume, const fs::path& wavPath, int slot
newDocument = rc0::replaceSlotBody(memoryText, slot, body);
}

const std::vector<std::string> existing = volume::listSlotWavs(volume, slot);
// The take's track, on every model: the first (kFirstTrack); the
// one-track model's folder is that track's.
const std::vector<std::string> existing =
volume::listTrackWavs(volume, family, slot, kFirstTrack);
if (!existing.empty() && !options.force) {
std::string files;
for (const auto& f : existing)
Expand All @@ -744,7 +782,7 @@ inline PushResult push(const fs::path& volume, const fs::path& wavPath, int slot
requireMemoryJournal(options.write);
if (options.write.journal.slotsChanging)
options.write.journal.slotsChanging({ slot });
const fs::path dir = volume::wavDir(volume, slot);
const fs::path dir = volume::trackDir(volume, family, slot, kFirstTrack);
std::error_code ec;
fs::create_directories(dir, ec);
if (ec)
Expand Down
30 changes: 21 additions & 9 deletions core/include/loopercat/DeviceProfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
//
// The operation set is the guard's other half. Knowing a model is not the
// same as being allowed to touch its card: the two-track model is known here
// and opened one operation at a time, for the ones that carry every track —
// pull, rename, clear and restore — and One Shot, which names its track. The
// others work on the first track alone
// (push, trim, downmix, normalize, tempo) or move only its audio (swap), and
// would corrupt such a card silently; on this table they are not untested on
// it, they are unreachable.
// and opened one operation at a time — for the ones that carry every track
// (pull, rename, clear and restore), for One Shot, which names its track,
// for push into a memory with no take on either track, and for Play
// Count-In, whose section the card lays out as the RC-5 does. The others
// work on the first track alone (trim, downmix, normalize, tempo) or move
// only its audio (swap), and would corrupt such a card silently; on this
// table they are not untested on it, they are unreachable.

#pragma once

Expand Down Expand Up @@ -368,12 +369,23 @@ inline constexpr std::string_view kRc500FactorySections = R"(
// (model id 00 00 00 77 answers, 76 and 78 are silent; Identity Reply family
// 0x0377), ioreg (product id 0x0252). Open: reading, the operations that
// carry every track of a memory — pull, rename, clear, restore (decided for
// 0.9.6, 2026-10-18) — and One Shot, which the pedal keeps per track and the
// app sets per track (decided 2026-10-29). Everything else is refused.
// 0.9.6, 2026-10-18) — One Shot, which the pedal keeps per track and the
// app sets per track (decided 2026-10-29), push, which this model takes
// into a memory with no take on any track and refuses elsewhere (decided
// 2026-10-29; the rule is push's, Commands.hpp), and Play Count-In, whose
// three fields live in <RHYTHM> — a section this card lays out as the RC-5
// does, field for field, with the RC-5's numbers where they were read: a
// memory saved on the pedal with the rhythm on, pattern Blank, beat 4/4
// reads State 1, Pattern 57, Beat 2 (hardware, 2026-11-07; Rc0.hpp,
// Beat.hpp). PlayCount's 1 = 1MEAS is the RC-5's reading (2026-08-10)
// carried over on that layout, and the first count heard from this pedal
// is what confirms it. The pattern and kit lists themselves are charted
// for the RC-5 only, so the rhythm card stays closed. Everything else is
// refused.
inline constexpr DeviceProfile kRc500 {
"RC-500", { 0x00, 0x00, 0x00, 0x77 }, 0x0252, 2, 99, kRc500FactorySections,
operations({ Operation::read, Operation::pull, Operation::rename, Operation::setOneShot,
Operation::clear, Operation::restore })
Operation::setCountIn, Operation::push, Operation::clear, Operation::restore })
};

inline constexpr std::array<const DeviceProfile*, 2> kAll { &kRc5, &kRc500 };
Expand Down
7 changes: 4 additions & 3 deletions tests/card_permissions_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ int main()
CHECK_EQ(rc5.footer(true), std::string("Disconnect to hear the changes."));

const CardPermissions rc500 = CardPermissions::of("RC-500");
CHECK(rc500.rename && rc500.oneShot && rc500.pull && rc500.clear && rc500.restore);
CHECK(!rc500.tempo && !rc500.countIn && !rc500.push && !rc500.swap
CHECK(rc500.rename && rc500.oneShot && rc500.countIn && rc500.push && rc500.pull
&& rc500.clear && rc500.restore);
CHECK(!rc500.tempo && !rc500.swap
&& !rc500.normalize && !rc500.trim && !rc500.rhythm && !rc500.playStop && !rc500.downmix);
CHECK(rc500.anyWrite()); // a rename is a write; the sweep and the face follow it
const std::string sentence = "On the RC-500, LooperCat does rename, set one-shot, pull, clear and restore only";
const std::string sentence = "On the RC-500, LooperCat does rename, set one-shot, set count-in, push, pull, clear and restore only";
CHECK_EQ(rc500.closed, sentence);
// The inspector can rename: it promises the change, and says what stays closed.
CHECK_EQ(rc500.footer(true), "Disconnect to hear the changes. " + sentence + ".");
Expand Down
Loading