# Pancakes

Hey!

Just a few quick updates. *Christmas is near* and I have stuff to do (i.e. think about what kind of cholocate sweets I should get for my parents).

I also have to study for the last part of Information Theory, but since I still have a couple of weeks ahead I can take my time for a few days.

For a few weeks after working on the CAA I’ve been up to pretty much nothing except one major event which was a super fun meeting of a super secret (not really) group of friends in Bologna.

Apart from that, I just bought a Konica pop but I still had no occasion on taking pictures with it. So apparently up to a few days ago, everything was boring and I had nothing to do.

That was, until I got inspired from some instagram lurking to make some music using 16/32-bit
era videogames samples. It’s not the first time that I try to do it (in fact I’ve been using SNES soundfonts on a large number of attempted songs),
however this time I think I got something right, which is **volume control**. You see, despite making music for 8 years, I’ve always been pretty bad
at making volumes sound right, especially when trying to limit stuff and avoid clipping.

So, I’ve been cooking up this track (I called it “Frittelle” which is something kinda like “Pancakes”).

## Frittelle

It was made with:

- 808 drum samples,
- a lot of SNES soundfonts sampled from various games,
- some vinyl recording noise,
- a bit of slowed down nanoloop 2,
- a small yamaha fm keyboard recording,
- a little guitar layer on the reprise

I get the feeling that despite being clearly not my best track musically speaking, it may be a good “technical” achievement in learning how to make music on a DAW, which is something I’m not really good at right now.

## CAA for more complex animations

Anyway, today was the last day of lectures and after getting back from the university,
I slacked off a bit and then started thinking about a way to use my **CAA** project to make a music video for Frittelle. Or a music video,
more in general.

I soon got to the conclusion that *it’s still too early to be thinking about something that complex* but I’ve started moving in the right direction.

I got a couple of interesting results based on a really simple concept, which is to **divide** the whole time window of the animation
in **smaller sub-windows** and change the equations according to some rules. As a signal analogy, I’m basically making the thing non-stationary.

It isn’t much of an interesting workflow since the same result could have been achieved already by running the program in separate instances and
then assembling the result as a whole. That is indeed the preferred choice when working on a big project, but for a 10 seconds animation the idea
of dividing the animation in sub-animation through time windows works faster.
It also allows for a *better control on the transitioning* to make it look natural, imposing that the starting point of equation B coincides with
(or is somewhere near to) the end point of equation A. I’ll better explain it through an example.

# Glitchy line breaks example

First of all, I define:

```
r = t % SINEDURATION;
```

which will help me understand in which section of the whole sine period we are. (Note that at the moment SINEDURATION is a quantity related to the number of frames being generated).

Then I define a double-type variable called *special* (sorry that I couldn’t think of a more appropriate name)
accordingly to conditions on the section of the sine period we are in:

```
// If positive ascending or negative descending sine regions (1st and 3rd quadrants)
if((r<SINEDURATION/4)||((r>SINEDURATION/2)&&(r<SINEDURATION*3/4))){
special = (double) (x-y);
// If positive descending (2nd quadrant)
} else if((r>SINEDURATION/4)&&(r<SINEDURATION/2)) {
special = (double) (x-y+(x^t)*sin((double)(t%(SINEDURATION/4))*2*PI/(SINEDURATION/4)));
// If negative ascending (4th quadrant)
} else {
special = (double) (x-y+(y^t)*sin((double)(t%(SINEDURATION/4))*2*PI/(SINEDURATION/4)));
}
```

At this point I have three different cases for the value of *special* according on the time position.

Notice that *right before the beginning of the 2nd quadrant, the sin() coefficient* inside the formula of *special* **assumes value equal to 0**,
which means that **the transition from 1st to 2nd quadrant sections is smooth** since *special* still equals (x-y), and only then it starts modifying the shape.

If the sin() assumed, at the moment of transition, the value 1, the animation would “jump” to a completely different looking frame in a very chaotic manner,
and we want to avoid that.
This holds also for all the other quadrant transitions.

At this point, based on the value of *special*, which is our time-window-dependant variable, we can define our colors!

```
color[0] = 40 + (char) (2*sin(((double)t * 2 * PI)/SINEDURATION) * special) % 100;
color[1] = (char) (2*sin(((double)t * 2 * PI)/SINEDURATION) * special);
color[2] = 120 + (char) (2*sin(((double)t * 2 * PI)/SINEDURATION) / special) % 50;
```

The result is kinda pretty, and shown here:

# Sierpinski glitchy example

This one is very similar to the previous one, but the glitch consists in the generation of a weird sierpinski pattern instead of breaking the lines.

This part changes (with respect to the previous code snippet):

```
// If positive ascending or negative descending sine region
if((r<SINEDURATION/4)||((r>SINEDURATION/2)&&(r<SINEDURATION*3/4))){
special = (double) (x-y);
} else {
special = (double) (x-y+(x^y)*sin((double)(t%(SINEDURATION/2))*2*PI/(SINEDURATION/2)));
}
```

while the rest is the same! The result:

I hope these examples were of interest! As always don’t mind giving me some feedback on this stuff, it’d be very much appreciated! Until next time, and happy holidays!