-
Notifications
You must be signed in to change notification settings - Fork 56
Adds support for the VIBrato command to SampleInstrument #1234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
f3ff5cf
06715ff
eb7c2e2
71b38f8
da480d6
e5a443d
06521e3
053f1f9
1ac8d5f
697f305
4024e20
4a09c94
2b9006f
b4aa0e5
ed736c3
9cd101d
164e453
7ff837b
b3ff955
fb01c2c
ddb4016
0154e52
aa7ae4a
d6cdc01
c33255b
1a5060d
6d8ad45
ef6e803
6310bb7
bcca409
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,10 +10,10 @@ | |
| #include "SampleInstrument.h" | ||
| #include "Application/Instruments/Filters.h" | ||
| #include "Application/Model/Table.h" | ||
| #include "Application/Player/PlayerMixer.h" // For MIX_BUFFER_SIZE.. kick out pls | ||
| #include "Application/Player/SyncMaster.h" | ||
| #include "Application/Utils/fixed.h" | ||
| #include "CommandList.h" | ||
| #include "Foundation/Constants/SineTable.h" | ||
| #include "SamplePool.h" | ||
| #include "SampleVariable.h" | ||
| #include "Services/Audio/Audio.h" | ||
|
|
@@ -1433,6 +1433,19 @@ void SampleInstrument::ProcessCommand(int channel, FourCC cc, ushort value) { | |
| if (crush > 0) | ||
| rp->crush_ = crush; | ||
| } | ||
|
|
||
| case FourCC::InstrumentCommandVibrato: { | ||
| uint8_t rate = value >> 8; | ||
| uint8_t depth = value & 0xFF; | ||
| // setup the vibrato | ||
| rp->vibrato_.SetData(rate, depth); | ||
| if (!rp->vibrato_.Enabled()) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is likely not going to work well with VIB cmds in tables combined with phrases.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem to cause any issues when applying a bunch of Vibrato commands from both tables and phrases simultaneously. What issue are you referring to? |
||
| // enable and add to active updaters | ||
| rp->vibrato_.Enable(); | ||
| rp->activeUpdaters_.push_back(&rp->vibrato_); | ||
| } | ||
| } break; | ||
|
|
||
| default: | ||
| break; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,10 @@ static char **getHelpLegend(FourCC command) { | |
| result[0] = (char *)("MIDI Chord:abcd"); | ||
| result[1] = (char *)("send rel notes:+a,+b,+c,+d"); | ||
| break; | ||
| case FourCC::InstrumentCommandVibrato: | ||
| result[0] = (char *)("VIBrato:aabb"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its not enough for this to be added to the onscreen help, it needs to be properly documented in both editions of the user manual. |
||
| result[1] = (char *)("rate aa, depth bb"); | ||
| break; | ||
| default: | ||
| result[0] = result[1] = (char *)(""); | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * | ||
| * Copyright (c) 2026 xiphonics, inc. | ||
| * | ||
| * This file is part of the picoTracker firmware | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| // 64-step (+ sentinel) sine wave lookup table (full cycle) | ||
| // sin(2 * pi * index / 64) * 32767 | ||
| constexpr int16_t sine_i16_64[65] = { | ||
|
n1LS marked this conversation as resolved.
Outdated
|
||
| 0, 3212, 6393, 9512, 12539, 15446, 18204, 20787, 23170, | ||
| 25329, 27245, 28898, 30273, 31356, 32137, 32609, 32767, 32609, | ||
| 32137, 31356, 30273, 28898, 27245, 25329, 23170, 20787, 18204, | ||
| 15446, 12539, 9512, 6393, 3212, 0, -3212, -6393, -9512, | ||
| -12539, -15446, -18204, -20787, -23170, -25329, -27245, -28898, -30273, | ||
| -31356, -32137, -32609, -32767, -32609, -32137, -31356, -30273, -28898, | ||
| -27245, -25329, -23170, -20787, -18204, -15446, -12539, -9512, -6393, | ||
| -3212, 0, | ||
| }; | ||
|
|
||
| // 16bit interpolation for 64-step sine table | ||
| static inline int32_t sine_i16_interpolated_64(uint16_t phase) { | ||
| // index into the table (top 6 bits) and fractional part (lower 10 bits) | ||
| uint8_t index = phase >> 10; // 0..63 | ||
| int32_t frac = phase & 0x03FF; // 0..1023 | ||
|
|
||
| // fetch table values | ||
| int32_t a = sine_i16_64[index]; | ||
| int32_t b = sine_i16_64[index + 1]; | ||
|
|
||
| // a + ((b - a) * frac) / 1024 | ||
| return a + (((b - a) * frac) >> 10); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having reset here is likely to cause issues with cmd usage in a table, so we really want phase reset to be separate and do the phase reset only when a vibrato cmd first starts
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maks I moved the vibrato reset to Start() so that a vibrato always starts at 0 without any jump in frequency. A second reset might helpful when calling
ARP 0000so that a later arp command cannot start with a jump in the frequency. What are your thoughts on that?