Files
JIANT/ports/juce-plugin/Source/JiantLook.cpp
T
Claude 8a8c0d04af JUCE plugin: samples, dropped or loaded, recorded, saved in the session
Audio files (WAV, AIFF, FLAC, MP3, OGG through JUCE's format manager)
dropped anywhere on the editor, or loaded from the new sample browser
(16 slots: pick, LOAD, CLEAR, name, length, channels), are made into
sample objects on the message thread and handed to the audio thread by
pointer; jiant_service runs on a 100 ms service timer. JIANT's own REC
works: the master and tracks, and the input when the host gives the
plugin its new Input bus (off by default, not on AU), resampled to
44.1 kHz with the output. The state embeds every slot's audio as FLAC
(lossless) with its name and file, cached between saves.

sample_check: a WAV dropped on the editor lands in slot 1 and SAMPLE
plays it, REC MST records a bar into slot 2, a new instance restores
both and plays them; plugin_check loads that state into the built VST3.
The editor's fonts (DotGothic16, IBM Plex Mono, OFL) are embedded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVqsRpEnNJfjWWrH3C4opq
2026-11-23 14:07:35 +00:00

86 lines
3.6 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant)
#include "JiantLook.h"
#include "BinaryData.h"
namespace jlook {
juce::Typeface::Ptr dotTypeface()
{
static juce::Typeface::Ptr t =
juce::Typeface::createSystemTypefaceFor(BinaryData::DotGothic16ascii_ttf, BinaryData::DotGothic16ascii_ttfSize);
return t;
}
juce::Typeface::Ptr monoTypeface()
{
static juce::Typeface::Ptr t =
juce::Typeface::createSystemTypefaceFor(BinaryData::IBMPlexMonoSemiBold_ttf, BinaryData::IBMPlexMonoSemiBold_ttfSize);
return t;
}
void paintBody(juce::Graphics& g, juce::Rectangle<float> r, float grid)
{
g.setColour(bg);
g.fillRect(r);
g.setColour(juce::Colour(0x12efe6c8));
for (float y = r.getY() + grid * 0.5f; y < r.getBottom(); y += grid)
for (float x = r.getX() + grid * 0.5f; x < r.getRight(); x += grid)
g.fillRect(x, y, 1.0f, 1.0f);
juce::ColourGradient heatLine(heat(0), r.getX(), 0, heat(1), r.getRight(), 0, false);
for (int i = 1; i < 5; ++i)
heatLine.addColour(i / 5.0, heat(i / 5.0f));
g.setGradientFill(heatLine);
g.fillRect(r.getX(), r.getY(), r.getWidth(), 3.0f);
}
void brackets(juce::Graphics& g, juce::Rectangle<float> r, juce::Colour c, float len, float w)
{
g.setColour(c);
const float x0 = r.getX(), y0 = r.getY(), x1 = r.getRight(), y1 = r.getBottom();
g.fillRect(x0, y0, len, w); g.fillRect(x0, y0, w, len);
g.fillRect(x1 - len, y0, len, w); g.fillRect(x1 - w, y0, w, len);
g.fillRect(x0, y1 - w, len, w); g.fillRect(x0, y1 - len, w, len);
g.fillRect(x1 - len, y1 - w, len, w); g.fillRect(x1 - w, y1 - len, w, len);
}
void ring(juce::Graphics& g, juce::Point<float> c, float radius, float v, juce::Colour arc, bool bipolar, float thick)
{
const float a0 = -0.75f * juce::MathConstants<float>::pi, a1 = 0.75f * juce::MathConstants<float>::pi;
v = juce::jlimit(0.0f, 1.0f, v);
juce::Path track;
track.addCentredArc(c.x, c.y, radius, radius, 0, a0, a1, true);
g.setColour(line.withAlpha(0.35f));
g.strokePath(track, juce::PathStrokeType(thick, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
const float from = bipolar ? 0.0f : a0, to = a0 + (a1 - a0) * v;
if (std::abs(to - from) > 1e-3f) {
juce::Path val;
val.addCentredArc(c.x, c.y, radius, radius, 0, std::min(from, to), std::max(from, to), true);
g.setColour(arc);
g.strokePath(val, juce::PathStrokeType(thick, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
}
// the value's point, cream on the arc's end
const float px = c.x + radius * std::sin(to), py = c.y - radius * std::cos(to);
g.setColour(cream);
g.fillEllipse(px - thick * 0.6f, py - thick * 0.6f, thick * 1.2f, thick * 1.2f);
g.setColour(panel);
g.fillEllipse(c.x - radius + thick * 1.6f, c.y - radius + thick * 1.6f, 2 * (radius - thick * 1.6f),
2 * (radius - thick * 1.6f));
g.setColour(line);
g.drawEllipse(c.x - radius + thick * 1.6f, c.y - radius + thick * 1.6f, 2 * (radius - thick * 1.6f),
2 * (radius - thick * 1.6f), 1.0f);
}
void button(juce::Graphics& g, juce::Rectangle<float> r, const juce::String& text, bool lit, bool held, juce::Colour on,
float font)
{
g.setColour(lit ? on.interpolatedWith(bg, 0.82f) : panel);
g.fillRect(r);
g.setColour(held ? cream : lit ? on : on.withAlpha(0.45f));
g.drawRect(r, held ? 2.0f : 1.25f);
g.setColour(lit ? cream : ink);
g.setFont(dot(font));
g.drawFittedText(text, r.toNearestInt().reduced(2, 0), juce::Justification::centred, 1, 0.8f);
}
} // namespace jlook