BACKSLASH HOTKEY SCRAMBLES YOUR INSTRUMENT'S PITCHES: a new feature for the open-source project The Amanuensis: Automated Songwriting and Recording

in #utopian-io6 years ago (edited)

amanuensis final-03.png
logo by @camiloferrua

Repository

https://github.com/to-the-sun/amanuensis

The Amanuensis is an automated songwriting and recording system aimed at ridding the process of anything left-brained, so one need never leave a creative, spontaneous and improvisational state of mind, from the inception of the song until its final master. The program will construct a cohesive song structure, using the best of what you give it, looping around you and growing in real-time as you play. All you have to do is jam and fully written songs will flow out behind you wherever you go.

If you're interested in trying it out, please get a hold of me! Playtesters wanted!

New Features

  • What feature(s) did you add?

A backing track or other source of music you're playing along with will most likely be in a certain key/scale, but with all of the dynamic and unconventional instruments it's possible to play The Amanuensis with, you may find yourself unable to play in tune with one. In the case of a monochromatic instrument or something a little crazier like a game controller, not all of the pitches you may want to use may be represented. If the source is coming from The Singing Stream each pitch can be chosen manually, but this is really meant to be done once during setup and not have to be changed again.

Therefore, it would be convenient to have a way to change the pitches on your instrument quickly and efficiently without having to take yourself out of the moment. Now the pitches on any instrument's track can be scrambled (or randomized, by octave, without duplicates) by hitting the backslash (\) key and returned to their default with bar (|, a.k.a. SHIFT+\).

Obviously a random set of pitches is not guaranteed to contain exactly the ones you need to work with, but without getting too deep into music theory, no matter the scale about half of the 12 pitches per octave are going to be "good" ones, so the chances really aren't too bad for finding at least a few pitches you can work with. You can test some out, and if you don't like what you're hearing you can always just hit the hotkey again to get a fresh set. In this way it shouldn't be too difficult to quickly dial up something workable in any situation.

And aside from the practical aspect, it can also be a fun way to challenge yourself. The Amanuensis is meant to be a game, after all. If you're anything like me, you can find yourself getting bored with the same old familiar patterns and scales on your instrument and the idea of hitting a button to suddenly have your keyboard or fretboard wiped clean, new and fresh for you to explore, is a very enticing one.

  • How did you implement it/them?

If you're not familiar, Max is a visual language and textual representations like those shown for each commit on Github aren't particularly comprehensible to humans. You won't find any of the commenting there either. Therefore, I will present the work that was completed using images instead. Read the comments in those to get an idea of how the code works. I'll keep my description here about the process of writing that code.

These are the primary commits involved:

In assessing this new idea, scrambled pitches are really only relevant for tonal instruments and the tonal instruments used within The Amanuensis are its suite of VST synths. Any guitars or the like sending a signal in through audio inputs are obviously beyond the system's control. Therefore the section of code that does the actual pitch translation was placed in synth.maxpat.


the new scrambled_pitch subpatcher in synth.maxpat, complete with commenting

At first I was contemplating adding a new option to the "shuffle" menu, but in the end what I was looking for was the ease of the new hotkey and so two new subpatchers were added to midiports.maxpat, utilizing the respective output from key.


the new scramble_pitches subpatcher in midiports.maxpat, complete with commenting


the new reset_pitches subpatcher in midiports.maxpat, complete with commenting

At first I thought of a function that would simply randomize the pitches assigned to any specific device in The Singing Stream, but I wanted the effect to go beyond the instruments handled there to any being used to play MIDI. The next natural place to store this information was with the "sounds" of each track, along with the current synth, preset and set of samples. This meant however that it would not strictly be instrument-specific, because if multiple instruments were on the same track all of their pitches would be scrambled, which seemed like a fine trade-off.

These pitches differed from the other sound data however in that it was not something I wanted to re-randomize every time a new sound was chosen (PGUP). It was determined that this was actually a track-specific attribute like current and total, so they were grouped together. Storing scrambled pitches with the sounds allows them to be imported and exported project by project, as is desirable, and with no UI object to save their state they will not be recalled by default between sessions.


the new initialize_track-specific_sounds subpatcher in soundcues.maxpat, complete with commenting


the new send_track-specific_sound_cues subpatcher in soundcues.maxpat, complete with commenting

It was realized that hitting one of these new hotkeys during play could easily cause a stuck note. Therefore, the input MIDI would need to be flushed before the change occurred. If possible, flushing only the channel in question would be desirable. Looking at the flow through the system, the one place where MIDI always passed that could easily be affected by channel was polyinput.maxpat and its 16 different voices, so this patcher was renovated.


the reworked portion of polyinput.maxpat, complete with commenting

I took this opportunity to look over the whole program and assess any other chokepoints which could also cause stuck notes and a handful were found. In some cases, the flush required could not be done by channel so a command to flush all channels at once (-1) was instituted. With this update flush commands have been integrated into the code in many places, including when the recording sources menu is changed as well as when the system enters a busy state (imports, exports, etc.)

GitHub Account

https://github.com/to-the-sun

To see a full history of updates, blog posts, demo songs, etc., check out my Steemit blog @to-the-sun.


Until next time, farewell, and may your vessel reach the singularity intact

To the Sun

Sort:  

Thank you for your contribution.

Your post is well written and adds a lot of documentation/explanation to the project. It is also good that you link to these utopian posts in the project README.md

The maxpat files are in fact JSON data, so you can't have comments in there, I am curious is there any other visualisation tool e.g. web tool, apart from the desktop software you are using (the screenshot)? It is not esay to understand those changes you've made without explicitly knowing the maxpat language, music/art, comments, or any visualisation. Do these changes work? how do you test them? :P

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

The only way to look at the code is with the Max software, which you can download a trial version of. You can also run it and test it that way, which I would love for you to do! Just follow the tutorials in the README (as a side note, a couple things have probably changed in those tutorials by now for the better, such as not needing Python anymore). And yes, the changes absolutely do work! :) I test them daily while I'm working on the code and also every night when I playtest it for fun.

Thank you for your review, @justyy! Keep up the good work!

Congratulations @to-the-sun! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 3000 upvotes. Your next target is to reach 4000 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Carnival Challenge - Here are the winners
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Hi @to-the-sun!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @to-the-sun!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!