Tutorial

Editing Expressions
RPN (Reverse Polish Notation)
Bitwise Logic


Editing Expressions

Glitch Machine’s editor allows 16 lines of “code,” and each line can contain up to 16 operators and/or numbers. The separate lines just make editing easier, and also allow you to use the line-muting feature (tap/click a line of code to mute/unmute it).

It doesn’t matter how much or how little code goes on each line… the whole expression behaves as one line of code.

This:

t 2 * t 5 >> |

Is the same as this:

t 2 *
t 5 >> |

Which is the same as this:

t
2
*
t
5
>>
|

The expression is simply calculated left to right, top to bottom, once per time tick (t).


RPN (Reverse Polish Notation)

With RPN you enter the numbers first, and then the operator, unlike typical “infix” mathematical notation. So:

infix:

1 + 2 * 3

Looks like this in RPN:

1 2 + 3 *

The numbers are placed on a “stack,” which in Glitch Machine has a limit of 256 values. You push numbers onto the stack simply by entering them in the editor:

1 2 3 4 5

This puts five values on the stack. They are pushed onto the stack in order from left to right; 1 is on the bottom of the stack, and 5 is on top. Doing the following:

+

…adds the top two values on the stack, which in this case results in 9. Thus, the stack now contains the values [1 2 3 9].

Typing in the following will give you 15 as a result:

1 2 3 4 5
+ + + +

Here is another way to express the same calculation:

5 4 + 3 + 2 + 1 +

At the end of your expression, Glitch Machine takes the top value of the stack and converts it to audio output. If the status at the top of the screen says “stack:1″ then there is one number on the stack, which is enough for Glitch Machine to make sound. Any value for the stack greater than 0 will produce output.

It is OK to leave more than 1 value on the stack, but only the top value will be used. These extra stack values may be used to create a sequence of notes, or read in a future sample update (using PICK) as a form of audio feedback.

If the stack value reports 0, or a negative number, then this is a stack underflow; no sound will be produced.


Bitwise Logic

Some of operators are “bitwise” operators, meaning they operate on the digital representation of the numbers themselves, which are formed from strings of binary “bits” or 1′s and 0′s. Wikipedia’s entry on Bitwise operation.

Glitch Machine uses the following bitwise operators:

| (OR)
& (AND)
^ (XOR)
~ (NOT)
>> (shift right)
<< (shift left)

The | operator is especially useful for mixing different elements of your expression together. The >> operator is often used to create timed beats and note sequences. For example:

t 4 >>

…shifts the ‘t’ value to the right by 4 bits, which effectively divides it by 16 (right-shifting by 1 bit divides the input value by 2). This creates a sawtooth waveform with a frequency of ~1.95Hz. Now, mix this with a simple sawtooth note (t 2 *), using the | operator:

t 4 >>
t 2 * |

Multiple beats can be mixed for more a complex pattern:

t 4 >>
t 5 >> |
t 2 * |

This tutorial is a work in progress. If you have specific questions you’d like answered in the tutorial, then leave a comment below!

TwitterFacebookGoogle+

20 comments on “Tutorial

  1. Could you explain what a “stack” is and what it means when you have a negative stack or more than one stack. Thanks!

  2. im assuming by stack he means like a programming stack as in like a stack of books.. if u take 1 from the bottom they all move down etc.. maybe not tho heh.. at first look i cant get my head round the RPN ;p

  3. @pizzadinosaur on said:

    Ah, so the entire thing is one linear string no matter how you separate them on the lines of code… interesting. As someone who’s been flying blind the last couple of days, I think the thing to explain next is why >> and | typically get sounds to “appear”, and an explanation as to what causes melodious elements and repetitious elements. Armed with just those two things I think a beginner can make a cornucopia of sounds and then branch out from there.

  4. Dev Bhatt on said:

    I completely agree with @pizzadinosaur

    This is an amazing app with much depth and some of the example songs are mindblowing!

    I feel that we do need a little bit more to get complete beginners like myself started…

  5. KarasuTengu on said:

    I agree that this app is a lot of fun, however, I do think a downloadable manual with more in depth instructions is needed. Also, I would love to see a sequencer implemented. It would be great to have a second “pattern/song” screen that would be divided into 9 or 16 “pads” upon which we could assign parts and toggle between parts. This would make this app much more viable for performance and recording.

    • Hey KarasuTengu, I’m planning to add a pad just like you describe; in fact it was planned for launch initially, but I left out since it would have delayed the release. I agree about the docs, funny thing is this is all so experimental it’s a bit tricky to explain yet, heh. I’ll do what I can though!

      • KarasuTengu on said:

        that’ll be awesome…another cool thing is the way Noteplex allows users to upload and download their creations from within the app. It’s a great tool to be able to see and learn from other people’s discoveries.

  6. C.V. Gates on said:

    Your above explanation of the fundamentals goes a long way toward making GlitchMachine more comprehensible. That said, I’m still confused about how some folks have used the PICK function to create songs with varying melody lines (‘quiddit’ and ‘chalk 2,’ for example). So, I hope additions to the tutorial would touch on such stuff.

  7. Dennis on said:

    I found a good post on creating a sequencer.

    http://umlautllama.com/w2/?action=view&page=GlitchMachine
    ______________________________________
    0 10 11 12 13 Our list of note data
    1 t 11 >> 3 & “Slow down” the ticks A LOT, and mask it off to be just 0..3
    2 PICK Use the above 0..3 as references onto the stack

    At this point, the top of the stack contains 13, 12, 11, or 10, as time progresses. To slow it down change the “11″ on line 1 to a different number. To add more items to the list, add them in line 0, and then change the ’3′ in line 1 to be a different number.

    For example, this one walks through 8 items, and goes slower:

    0 19 20 21 20 19 20 21 99
    1 t 13 >> 7 & PICK

    From here, to hear rudimentary tones, add the following to multiply it out.

    3 t *

    In the above, we’re masking the value with 3 and 7. (b0011 and b0111) If you want to have a non-power-of-2 count to your list, you can modulo it instead, as shown in the following:

    0 99, 98, 97, 10, 3
    1 t 10 >> 5 % PICK
    _____________________________________

    This page also goes on to explain a lot of other interesting stuff. What specifically interested me was having the ability to integrate other music I’ve created on GlitchMachine with the sequencer (assuming they’d somehow sync up). My assumption is probably false since it takes a pretty intelligent machine to know how to automagically blend one piece to another. But let me know if I’m incorrect or if there’s a way to append other sounds to the stack and integrate them in some way to the existing string of “sequencer” code.

  8. I see that you can export as .wav. Where does the file save to? I’m not seeing the file name in iTunes. Is it on a clipboard somewhere? Is there a naming convention? I cant seem to find the file I saved.

  9. First off, great program. I too would love to see pads added, as well as record and pasteboard function, but even as is I keep coming back to Glitch (even over “pro” apps like Moog, Korg, etc.).

    Thing is, without the examples I’d be lost, as I’m having trouble figuring out even basic entry. Some suggestions:

    -short quick tutorials for basic stuff, rather than trying to explain the whole thing, so in other words ones for: tone, beat, melody

    -give examples to go along with each of these quick tutorials

    -then branch out into intermediate and advanced concepts

    This way we could follow along simply and easily, then make variations once we got comfortable with the language.

    Good stuff. Keep up the good work. Five star app!

    • Hey J.B. thanks! Glad you’re enjoying it over some pro apps, that’s encouraging. ;)

      Yes I agree it’s all rather tricky stuff. The thing is too, there’s no real “right” way to do anything… there’s so much that is really just about the sounds you get from experimentation. I’ve found that most of my stuff is more interesting when I don’t try to actually “compose” too much. Even so, there are certainly some basics that are worth covering. If the language itself is a huge barrier though, then I will definitely put more into tutorial-izing that stuff.

      The pads are actually a really great idea and a perfect fit for Glitch Machine… they are on the way in a future update. Pasteboard is in now, will be approved shortly. Curious how you’d expect a record option to work… record to WAV? Feel free to email me if you want to go into more detail.

  10. Hey there, I sent this within the comment and feedback section, but am not sure it made it through so here it is again:

    For tutorials the trouble I’m having is that often times I’ll write an entry and get no sound at all, so I was thinking that short examples would help, ones that showed just what needs to be done to get “the machine” up and running. Though I’m sort of thinking now that I just need to spend more time with it perhaps.

    For recording what I had in mind was something that recorded the output, which could then be copied to the pasteboard. The reason I say this is because in fooling around with it I almost think that Glitch Machine works as a live performance tool in some capacity, with the way you can mute lines and change data on the fly. You say pasteboard function is already in and waiting approval, so maybe you already have it set up this way? Well, if not, yeah I guess wav output would work best. Just something that could record what was being played live, and then copied and pasted into other apps. That is what I was thinking.

    Thanks, and looking forward to the updates.

  11. +1 for some tutorials that start at the real basic stuff (complete beginner) and then go on from there. Also, I would really appreciate the tutorials being video tutorials (with maybe text to go with them). I tend to learn by seeing and hearing people do stuff, so that would be great. Appreciate it all takes time and you’re a busy person though. And thanks for a great app.

  12. bonkersjupiter on said:

    I find this app really intriguing but I’d like to understand it more. I’m sure people would pay more for an app with relevant tutorials. I know I would. I love some of sounds you can get out of it but am relying too much on happenstance, at the moment. Thanks for a really cool app though & am looking forward to the new tutorials.

  13. Guajiro on said:

    Agreed, is there some way you could make a “total noob” tutorial from start to finish on how to understand the underlying code that is being used for this app? Even if it’s a list of third party resources where people can get to grips with how to code in this language, and understand what is going on in the lines of code :) maybe far fetched but I think it would bring more people to the app as it is totally awesome….. If you can figure out how it all works lol

  14. I hear your pleas regarding a tutorial. Seems to me that the best tutorials are collaborations within the community itself. How about we discover the answers in the forum, I’ve created a thread in the Glitch Machine forum: http://forums.madgarden.net/viewforum.php?f=3

    Then all of the best stuff can be used to update back this page. As the guy who wrote it, it’s hard to get the right perspective at times… and heck, even I don’t know how some of the sounds I make on my own happen. I experiment more than I calculate. But we can figure any of these things out… so, let’s do it up!

  15. Klaus on said:

    One silly question, where do I find the or “|” operator on the keyboard in glitch machine?

    • It’s right beside the & key in landscape view, and below it in portrait. It looks sort of like a : instead of a vertical stick. The font on this WordPress theme messes up that distinction I guess.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy This Password *

* Type Or Paste Password Here *

646 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>