Skip to content
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

Add Traffic script #311

Merged
merged 34 commits into from
Feb 9, 2024
Merged

Add Traffic script #311

merged 34 commits into from
Feb 9, 2024

Conversation

chrisib
Copy link
Collaborator

@chrisib chrisib commented Nov 13, 2023

New Script: Traffic

Adds a new script based on Traffic by Jasmine & Olive Trees. AIN and DIN are treated as gate inputs. CV1-3 outputs 5V * (din.value() * gain_1 + ain.value() * gain_2) where the gains can be set independently per channel.

CV4 and CV5 output the absolute difference between channel A and either channel B or C. CV6 outputs a trigger on every rising edge of either AIN or DIN.

To change the gains of channel B hold B1 while turning K1 and K2. Holding B2 will adjust the gains of channel C.

Dependencies

Depends on some changes in experimental implemented in #309.

@chrisib
Copy link
Collaborator Author

chrisib commented Nov 17, 2023

Rebase from latest g-and-t-v2 branch to remove unnecessary changes relating to the screensaver overhaul

@chrisib
Copy link
Collaborator Author

chrisib commented Feb 5, 2024

Now that #309 has been merged I've re-sync'd my main and rebased this branch to match with it.

@roryjamesallen roryjamesallen added the new script Addition of a new contrib script label Feb 6, 2024
Copy link
Collaborator

@mjaskula mjaskula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code itself here looks pretty good, I just had a few suggestions.

I'm not sure I entirely understand it, as mentioned in a comment, so I'm gonna wait to complete my review until I understand it a little more.

The Jasmine and Olive Trees site says "Imagine having 3 triggers that will instantly set a BIA or Plaits as a kick, snare, and hi-hat." This is in line with a script idea that's been bouncing around in my head for a while now. So I'm excited to understand this more fully.

self.save_state()

@b2.handler_falling
def b2_falling():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] This function appears to be the exact same implementation as b1_falling(), why not use the same actual function?

if time.ticks_diff(now, self.last_trigger_at) > TRIGGER_DURATION:
cv6.off()
else:
cv6.voltage(TRIGGER_VOLTAGE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[discussion] Should this instead use cv6.on() to take advantage of the configurable gate voltage being introduced in PR #331?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I suspect a few scripts would benefit from that change in the long run.

software/firmware/europi.py Outdated Show resolved Hide resolved


class AnalogReaderDigitalWrapper:
"""Wraps an AnalogReader to allow it to simulate a DigitalReader"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[required] I would like to see some text here describing the intended use of this class. Specifically that the state returned by value() is only accurate as of the last call to update().

software/contrib/traffic.md Outdated Show resolved Hide resolved
…nsaver to G&T. Move the screensaver activation & blank timeouts into the Screensaver class itself instead of redefining them externally
…r & screen-blanking. Use this wrapper instead of europi.oled in the 3 scripts that use the screensaver
…irst and auto_show arguments to centre_text, modify all extant calls to centre_text to use the correct auto_show behaviour
Copy link
Collaborator

@roryjamesallen roryjamesallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding the UI pretty confusing, I can kind of tell that the right handle column of values is the voltage - it seems to always be 10x the value of column 1, which makes me wonder why it's there. To me it would seem to make more sense to remove the third column and use the room to add a V, making it clear each 'gain setting' is the voltage that will be output. As I write this I'm realising it could be the calculated output voltage based on the maximum voltage, but now that this is set in europi_config I think it's confusing to have it alongside the gains. I think it would be more intuitive to remove the third column altogether, possibly replaced by A B and C identifiers for each channel to make the grid of numbers more readable.

The other thing I noticed is that you can always change the output voltages of channel 1. The documentation leads me to believe that the outputs switch only on a positive trigger, but they seem to update continuously regardless of input for channel 1.

software/contrib/traffic.md Outdated Show resolved Hide resolved
software/contrib/traffic.md Outdated Show resolved Hide resolved
software/contrib/traffic.md Outdated Show resolved Hide resolved
software/contrib/traffic.md Outdated Show resolved Hide resolved
@chrisib
Copy link
Collaborator Author

chrisib commented Feb 8, 2024

I've simplified the GUI a little and added A/B/C labels to the rows + removed the third column.

The values do update continuously, which makes fine-tuning the levels easier. I've updated the documentation to reflect that. The triggers control which set of levels are being continuously applied, but it's not a sample & hold style behaviour; as long as din fired last, changing the gains for trigger 1 will apply immediately. Changing the gains for trigger 2 will only take effect if ain got a trigger most recently.

…rs -- the limit of human hearing is ~100ms, so half that should be close enough. This lets input 1 properly take priority when both signals trigger at almost the same time
@roryjamesallen
Copy link
Collaborator

I've simplified the GUI a little and added A/B/C labels to the rows + removed the third column.

Changes are all great, LGTM now! One suggestion is to increase the samples on knob reads as I find it difficult to not have it flickering now it's at 3 decimal places, and given the potential for accuracy with 3 d.p. and the continuous updating, it would be nice to make sure that fine tuning is really possible.

In a test I just did, 1024 samples for each percent() call resulted in much less flickering between values but still a responsive experience.

The final thing is that the use of the knob bank class results in behaviour which I'm personally not a huge fan of, which is that if the previous setting was all the way down for example, then you change to adjust a different one to all the way up, when you go back to edit the first you need to swing the knob completely back down to be able to adjust its value.
This is just a personal dislike, and I can see the benefit in that it prevents sudden changes in value due to a knob update, but I think it would be nice to mention in the documentation that this is the case as I initially thought it wasn't working until I tried scanning the knob fully CCW then CW again to 'unlock' it.

Both of the above are optional, and if you'd prefer not to implement them then this PR is ready to go:)

@chrisib
Copy link
Collaborator Author

chrisib commented Feb 9, 2024

Good call about the samples.

@roryjamesallen roryjamesallen merged commit 694f65b into Allen-Synthesis:main Feb 9, 2024
3 checks passed
@chrisib chrisib deleted the traffic branch February 9, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new script Addition of a new contrib script
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants