## Music represented through logic?

• 1,450 Views
• 35 Replies
Centriptic
Centriptic
• Member since: Dec. 9, 2012
• Offline.
Forum Stats
Member
Level 01
Musician
Music represented through logic? 2012-12-10 13:51:19

Has anyone ever tried to write a piece using computational logic?

For instance, heres a simple side-chained bass, kick, snare and hi-hat beat that covers 1 measure (I've combined some basics of a few languages to help this make a little more sense)

``````//Setup One Measure

beat=1
While beat < 17
if beat = 1 || 4 || 8 || 12  //When its the 1st ,4th ,8th or 12th beat, play kick sample
playKick; //Play Kick Sample
end
if beat = 4 || 12
playSnare; //Play Snare Sample
end
if beat%2 == 0 //If its a on-beat, play hi-hat
playHiHat; //Play Hi-Hat Sample
end
if (playKick) == True
Stop playBass; //Kill Bass Sample
else
playBass; //Play Bass Sample
end
beat = beat + 1;
End``````

You could probably wrap this in another loop that reiterates the measures to make a full song...

Anybody ever look at music like this?

Lachi
Lachi
• Member since: Sep. 29, 2012
• Offline.
Forum Stats
Member
Level 01
Musician
Response to Music represented through logic? 2012-12-10 14:13:39

Chords, basses and other elements are quite easy. Try to do that with a melody...

SUCK MY KICK

Buoy
Buoy
• Member since: May. 18, 2006
• Offline.
Forum Stats
Member
Level 40
Musician
Response to Music represented through logic? 2012-12-10 14:16:02

this seems terribly inefficient

Megamannt92
Megamannt92
• Member since: Mar. 22, 2006
• Offline.
Forum Stats
Member
Level 03
Musician
Response to Music represented through logic? 2012-12-10 14:23:22

Ugh. My brain.

I just play music.

Hey check out my music! Its guitarlicious or something.... Pirate Metal! | Rock with guest Female Vocalist

GACBassPlayer
GACBassPlayer
• Member since: Nov. 8, 2002
• Offline.
Forum Stats
Member
Level 22
Melancholy
Response to Music represented through logic? 2012-12-10 15:42:50

At 12/10/12 02:16 PM, Buoy wrote: this seems terribly inefficient

Inefficient was exactly the word that came to mind.

Centriptic
Centriptic
• Member since: Dec. 9, 2012
• Offline.
Forum Stats
Member
Level 01
Musician
Response to Music represented through logic? 2012-12-10 16:40:16

The point is not its in efficiency, but its concept. I agree it does sound like a pain in the ass and not quite practical, but I'm just curious about how it all could be modeled. I don't plan to use this method for a future song, but I wanna have another method of analysis to understand music.

That being said...

Why couldn't a melody be a randomized power-of-two value that that denotes 1/x for note length. Just make it legato from note to note. Have an array holding pitch values.

Lachi
Lachi
• Member since: Sep. 29, 2012
• Offline.
Forum Stats
Member
Level 01
Musician
Response to Music represented through logic? 2012-12-10 16:53:37

At 12/10/12 04:40 PM, Centriptic wrote: Why couldn't a melody be a randomized power-of-two value that that denotes 1/x for note length. Just make it legato from note to note. Have an array holding pitch values.

A melody is a sequence of notes, with various characteristics for each note, etc.
You could build a motif or something, and make it various throughout the time... It seems quite stupid, but I understand your point

SUCK MY KICK

Step
Step
• Member since: Nov. 4, 2007
• Offline.
Forum Stats
Moderator
Level 25
Musician
Response to Music represented through logic? 2012-12-10 17:06:46

On a related note, while right now it seems like a stupid idea, I do believe that one day a computer will be able to create chord progressions, melodies and sounds all on its own automatically, and eventually automatically generate a song that has a coherent structure, good melodies and sounds that fit with each other. I don't think a computer will be able to surpass the creativity and originality that a human being is capable of for a long long while, but I think this idea is very much a possibility.

Review Request Club | CHECK THIS OUT | Formerly Supersteph54 | I'm an Audio Moderator. PM me for Audio Portal help.

Centriptic
Centriptic
• Member since: Dec. 9, 2012
• Offline.
Forum Stats
Member
Level 01
Musician
Response to Music represented through logic? 2012-12-10 17:09:43

At 12/10/12 04:53 PM, Lachi wrote:
At 12/10/12 04:40 PM, Centriptic wrote: Why couldn't a melody be a randomized power-of-two value that that denotes 1/x for note length. Just make it legato from note to note. Have an array holding pitch values.
A melody is a sequence of notes, with various characteristics for each note, etc.
You could build a motif or something, and make it various throughout the time... It seems quite stupid, but I understand your point

You could make it random, as long as it played in key. It might take a 100 renders the generator, but I'd feel your bound atleast once to a get a melody out of it.

eatmeatleet
eatmeatleet
• Member since: Nov. 8, 2009
• Offline.
Forum Stats
Member
Level 11
Musician
Response to Music represented through logic? 2012-12-10 17:24:22

Exception thrown (uncought exception-your sound is clipping) lrn2code

Centriptic
Centriptic
• Member since: Dec. 9, 2012
• Offline.
Forum Stats
Member
Level 01
Musician
Response to Music represented through logic? 2012-12-10 17:58:43

At 12/10/12 05:24 PM, eatmeatleet wrote: Exception thrown (uncought exception-your sound is clipping) lrn2code

Nice...

Now that I think about it, you could even code a very basic delay FX.

WizMystery
WizMystery
• Member since: Feb. 3, 2009
• Offline.
Forum Stats
Member
Level 11
Musician
Response to Music represented through logic? 2012-12-10 19:13:33

You've discovered my secret plan >:(

But yeah, I'm going into computer science next semester and I want to make a video game that uses this sort of thing for the BGM. I tried doing it with midi before in C++ but my goal was randomization more than something palpable.

NinjaGuy
NinjaGuy
• Member since: Jul. 3, 2006
• Offline.
Forum Stats
Member
Level 20
Musician
Response to Music represented through logic? 2012-12-10 20:07:53

At 12/10/12 02:16 PM, Buoy wrote: this seems terribly inefficient

srsly, the point of code is to do a job with as little work as possible, music is feeling, and essentially, work. programming and logic are naturally the opposite of music and most forms of expressions. The only expression I can ever seem to find in coding is the method by which the solution is derived. Music is about the process, the patterns of the chord changes, the simplicity one may find in a less complex piece cannot rewrite the emotion or feeling placed in a song crafted entirely by ear.

Blackhole12
Blackhole12
• Member since: Sep. 21, 2006
• Offline.
Forum Stats
Member
Level 15
Game Developer
Response to Music represented through logic? 2012-12-11 00:47:03

Overtone is a Clojure library for procedurally building songs using functional constructs which explores this very idea.

Personally I've had an interest in building a synth library in Haskell or Scheme but don't have time to toy around with things like that. I did do some mathematical analysis, though.

Centriptic
Centriptic
• Member since: Dec. 9, 2012
• Offline.
Forum Stats
Member
Level 01
Musician
Response to Music represented through logic? 2012-12-11 01:35:03

At 12/11/12 12:47 AM, Blackhole12 wrote: Overtone is a Clojure library for procedurally building songs using functional constructs which explores this very idea.

Wow, right along the lines of how I was thinking... Too cool.

Heres a guy doing a whole set with it haha... http://vimeo.com/46867490

The-iMortal
The-iMortal
• Member since: Aug. 30, 2008
• Offline.
Forum Stats
Member
Level 04
Musician
Response to Music represented through logic? 2012-12-11 07:01:28

At 12/11/12 06:24 AM, Thief1337 wrote: A DAW fulfill this job for you already. Your job is to write music and be an alive spirit, not a robot.

I agree with this (though, I would use the term emotion rather than spirit). And this is coming from somebody who's spent 80% of audio/music time on production tools and synthesis; all the programming aspects of music.

I love all kinds of electronic music... well, most kinds. You can always tell when there's emotion put into a track. Even if there is no live recording, but all instruments have been programmed, you can hear some form of emotion in a good track. Many tracks, you cannot hear the emotion. Though, I don't think to myself, "OMG NO EMOTION," I think "sounds boring... like nothingness."

This is one aspect among many which separates the best electronic producers from the mediocre. I think Skrillex is an amazing producer, mainly for his sound-design skills, but as well for his music. Many people may argue he puts no emotion into his productions and it's all just sound, but I strongly disagree.

However, producers such as Excision and Datsik, as popular as these Dubstep producers are, I listen to their tracks and am bored shitless. To me, their tracks really sound like something just programmed in. No emotion. Of course, I have not listened to many tracks from these artists. I stopped when I realised they didn't do much for me.

So to answer OP's question:

At 12/10/12 01:51 PM, Centriptic wrote: Anybody ever look at music like this?

The answer is no.

dem0lecule
dem0lecule
• Member since: Feb. 17, 2008
• Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Music represented through logic? 2012-12-11 13:23:52

I use Chuck. I used to do live coding with friends for parties in college. Also use C++ in music for demoscene.

``````while( e > 0 )
{
e / 8.0 => buf.gain;
where => buf.pos;
(1.0/8.0)::T => now;
i--;
}``````

Or you can mess with stuff like frequency.

``````second / samp => float SR;
2 * pi * freq / SR => float omega;
SR / freq - .5 => float F;
F \$ int => int Fi;
F - Fi => float Ff;
polePos( Ff, omega ) => allpass.allpass;``````

I disagree with some on here. DAW might give you everything, but what you might not have is speed, especially when doing live. Music is just mathematical arrangement. Doing it with coding is quite the same as doing with DAW. DAW is just a compiled bunch of raw programming languages. FL Studio was written in VC++, Renoise in C++... doing raw coding with music can give you the power that compiled programs can't do. Example, you need a separate VST to do reverb, while it takes you 2 minute or so to write C++ codes just for reverb.

I had vast experiences in music programming, from live coding to doing music in 32kb music executable.

At 12/10/12 05:06 PM, Step wrote: On a related note, while right now it seems like a stupid idea, I do believe that one day a computer will be able to create chord progressions, melodies and sounds all on its own automatically, and eventually automatically generate a song that has a coherent structure, good melodies and sounds that fit with each other. I don't think a computer will be able to surpass the creativity and originality that a human being is capable of for a long long while, but I think this idea is very much a possibility.

Already had, just in mathematical form. I present you WolframTones, MaestroGenesis, Impromptu and god of all - cgMusic

I am also writing my own music generator :), 60% done.

What comes around goes around...

Blackhole12
Blackhole12
• Member since: Sep. 21, 2006
• Offline.
Forum Stats
Member
Level 15
Game Developer
Response to Music represented through logic? 2012-12-11 13:40:38

At 12/11/12 07:01 AM, The-iMortal wrote:
At 12/10/12 01:51 PM, Centriptic wrote: Anybody ever look at music like this?
The answer is no.

This is wrong, as many mathematicians and computer scientists have been studying musical patterns in an attempt to answer the question of what music sounds good to us and why. Seeing as our western system of tonality has a mathematical basis (to go up one octave, double the frequency), it seems obvious that there must be underlying patterns that we are identifying. One group, whom I no longer have a link to, used a genetic algorithm with human input to try and teach a computer how to create music. There have been numerous other attempts using markov chains and nondeterministic state machines at randomly generating music.

One particularly notable instance of this is the game Spore, which uses procedurally generated ambient music by randomly generating a melody based on note-compatibility in a markov chain and then assigning it to an instrument from a predesigned set of sounds. You just hit the "random" button and it'll randomly generate a melody for you.

There are other cases where a pentatonic scale is used in such a way that it eliminates dissonance between the possible notes, which allows a computer to simply randomly select notes and often come up with something that sounds good anyway. The infinitely popular tonematrix flash "game" used this to great effect. Otomata is another variation on this, except it has a whole slow of various strange scales to choose from.

So the short answer is "Yes", because a whole slew of very smart people have thought about music using logical constructs and mathematical logic. I'm sure the musicians here aren't very happy about that, of course.

Blackhole12
Blackhole12
• Member since: Sep. 21, 2006
• Offline.
Forum Stats
Member
Level 15
Game Developer
Response to Music represented through logic? 2012-12-11 15:54:33

At 12/11/12 02:14 PM, Thief1337 wrote:
At 12/11/12 01:23 PM, dem0lecule wrote: Music is just mathematical arrangement.
At 12/11/12 01:40 PM, Blackhole12 wrote: I'm sure the musicians here aren't very happy about that, of course.
Short answer.

See?

The-iMortal
The-iMortal
• Member since: Aug. 30, 2008
• Offline.
Forum Stats
Member
Level 04
Musician
Response to Music represented through logic? 2012-12-11 16:32:47

At 12/11/12 01:40 PM, Blackhole12 wrote: So the short answer is "Yes", because a whole slew of very smart people have thought about music using logical constructs and mathematical logic. I'm sure the musicians here aren't very happy about that, of course.

You do have a point. I guess alot of the emotion in "programmed" tracks is through the actual programming aka mixing, sound design etc, as well as melody. And who hasn't discovered good melodies by accident? Maybe it's the good "programming" which brings emotion into a track.

At 12/11/12 02:14 PM, Thief1337 wrote:
At 12/11/12 01:23 PM, dem0lecule wrote:
Music is just mathematical arrangement.

Short answer.

Unnecessary.

Nav
Nav
• Member since: Jan. 6, 2007
• Offline.
Forum Stats
Member
Level 17
Audiophile
Response to Music represented through logic? 2012-12-12 14:18:18

At 12/11/12 01:23 PM, dem0lecule wrote: I use Chuck. I used to do live coding with friends for parties in college. Also use C++ in music for demoscene.

I was always under the impression that demoscene artists used trackers.

Writing music directly in C++ doesn't sound very convenient... Why would you choose that over trackers? I mean, sure, you'll gain a small performance and size increase, but is the increase in pain-in-the-ass really worth it? :S

Nav
Nav
• Member since: Jan. 6, 2007
• Offline.
Forum Stats
Member
Level 17
Audiophile
Response to Music represented through logic? 2012-12-12 14:19:27

At 12/12/12 02:18 PM, Nav wrote: size increase

Excuse me, I meant a decrease in size (which is good news).

Axel7
Axel7
• Member since: Dec. 3, 2012
• Offline.
Forum Stats
Member
Level 03
Musician
Response to Music represented through logic? 2012-12-12 14:59:00

At 12/10/12 07:13 PM, WizMystery wrote: You've discovered my secret plan >:(

But yeah, I'm going into computer science next semester and I want to make a video game that uses this sort of thing for the BGM. I tried doing it with midi before in C++ but my goal was randomization more than something palpable.

I was JUST thinking as I read this thread "maybe good enough to randomly generate 8 bit music for games" XD

Blackhole12
Blackhole12
• Member since: Sep. 21, 2006
• Offline.
Forum Stats
Member
Level 15
Game Developer
Response to Music represented through logic? 2012-12-12 15:14:08

At 12/12/12 02:18 PM, Nav wrote: I was always under the impression that demoscene artists used trackers.

This is only sometimes correct. If you are writing a 64kb demo, you usually have to either write something specifically for that demo or come up with an extremely compact tracker of your own. It probably ends up being a weird combination of both.

dem0lecule
dem0lecule
• Member since: Feb. 17, 2008
• Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Music represented through logic? 2012-12-12 16:42:37

At 12/12/12 02:18 PM, Nav wrote:
I was always under the impression that demoscene artists used trackers.

Writing music directly in C++ doesn't sound very convenient... Why would you choose that over trackers? I mean, sure, you'll gain a small performance and size increase, but is the increase in pain-in-the-ass really worth it? :S

size increase
Excuse me, I meant a decrease in size (which is good news).

Sorry, I didn't state out clearly what type of demo. Well, using the scener's perspective, as an example how code can contribute masterly and greatly in music.

If it's size restricted demo such as 96kb, 64kb, 4kb, even 1kb demo and 32kb or 16kb music executable, then real time coding for music is a must. If it's just normal compo (real time but no size restricted), by any mean of making music such as using DAW or crazy enough to do real time, then it's no problem for any type of music making tool.

C++ is actually the easy one. Some people even use Assembly languages for smaller demos. Often, sceners write a base program or synth to compose music, but instead of data (e.g music files), they render codes. Sometime they will program the music, from scratch. Example of transparently real time synth are:

= TinyFM8 - the guy who created this, literally, reverse engineered the real FM8, recreate just for code rendering. If you want to render codes, you need Renoise.
= 4klang - this synth is the state-of-art demotool. Coded in C++. Example of prods it used in, legendary 64k Uncovering Static and 4k Rudebox.
= V2 Synthesizer - another state-of-art synth. Coded by kb (or kebby), shook the whole PC scene in 2000, with real-time Half-Life like graphic in 64k, .the .product, the whole music itself is about 7 minutes long: choir, drums, pads, lead, SFX.
= Quite's SamplePool - most transparent one. C++. Tracker based. 4k yes we can, as example.

Notice, all these synths above are smaller than 1 MB, and they are all as powerful as commercial synths. If you want to see rants about how it's all begun, this Pouet thread.

Some might not share their synth or secret freely, and most of us sceners are dying to see how the magic does in:
= 1 fucking Kilobyte Untraceable by TBC, included stunning music. I can't and never create stuff like this, with music.
= 4k Elevated by RGBA & TBC - stunning music and SFX.
= 64k Gaia Machina by Approximate - I guess they use DirectX for the sounds, maybe. Again, impossible for me or any of my crews to pull stuff like this.

For 32kb (or smaller) music, these are real time executables. There are several tricks, either use a tiny MOD player attaches with a MOD (very old, slightly newer I attach MO3 file), or render real time data with a tiny synth attached.

Example of musicians who do music-in-code:
= fr-028: brullwurfel by Farbrausch - whole player itself and music (11 songs) in 64 kilobytes. Impressive.
= Gargaj music - he's excellent at this. Example, Rude Awakening was in legendary 64k Chaos Theory demo. Commence/Collapse is a 17kb exe music.
= Punqtured - Og der var Ã¸repropper i infodesken, 16k. 32k music set, real instruments, he uses commercial synth Quiver, made by his group member.
= Gloom.

:/ in the end of the day, these guys can pull out music and sounds as amazing as DAW users do. I spent my time well to write this, just to prove how code can contribute greatly to music. We demosceners are not wizards, we only create music in very special ways.

What comes around goes around...

dem0lecule
dem0lecule
• Member since: Feb. 17, 2008
• Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Music represented through logic? 2012-12-12 17:59:28

Not self-advertising! Just an example for my previous post.

• Resetti (32k) by dem0lecule

32kb exe rendered music

Score
0 / 5.00
Type
Song
Genre
Drum N Bass
Popularity
3 Views

Rendered and uploaded this beast just-for this conversation. I do 32k executable music too. I still have to figure out how to pack the actual exe properly to upload, because antivirus flagged it as malware >.<

What comes around goes around...

eatmeatleet
eatmeatleet
• Member since: Nov. 8, 2009
• Offline.
Forum Stats
Member
Level 11
Musician
Response to Music represented through logic? 2012-12-12 18:29:21

At 12/12/12 05:59 PM, dem0lecule wrote: Not self-advertising! Just an example for my previous post.
http://www.newgrounds.com/audio/listen/514820
Rendered and uploaded this beast just-for this conversation. I do 32k executable music too. I still have to figure out how to pack the actual exe properly to upload, because antivirus flagged it as malware >.<

autism at it's best

deadlyfishes
deadlyfishes
• Member since: May. 15, 2011
• Offline.
Forum Stats
Member
Level 05
Musician
Response to Music represented through logic? 2012-12-12 18:51:15

At 12/10/12 01:51 PM, Centriptic wrote: Has anyone ever tried to write a piece using computational logic?

For instance, heres a simple side-chained bass, kick, snare and hi-hat beat that covers 1 measure (I've combined some basics of a few languages to help this make a little more sense)

//Setup One Measure

beat=1
While beat < 17
if beat = 1 || 4 || 8 || 12 //When its the 1st ,4th ,8th or 12th beat, play kick sample
playKick; //Play Kick Sample
end
if beat = 4 || 12
playSnare; //Play Snare Sample
end
if beat%2 == 0 //If its a on-beat, play hi-hat
playHiHat; //Play Hi-Hat Sample
end
if (playKick) == True
Stop playBass; //Kill Bass Sample
else
playBass; //Play Bass Sample
end
beat = beat + 1;
End

You could probably wrap this in another loop that reiterates the measures to make a full song...

Anybody ever look at music like this?

Yes, there is a whole genre of music based on creating music this way.

This is fixed media + piano
http://www.youtube.com/watch?v=UNcVjQUZ5VI

Also, there were some composers who would program music into a computer which then the computer would be another "instrument" in the ensemble:
http://www.youtube.com/watch?v=47BrzGW9DRg

http://www.youtube.com/watch?v=47BrzGW9DRg

<Professional Composer> <AudioJungle Reviewer>
OFFICIAL MUSIC SITE!
Check out something I did for NATA 2013! Hikarian's winning NATA 2013 Entry

dem0lecule
dem0lecule
• Member since: Feb. 17, 2008
• Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Music represented through logic? 2012-12-13 22:22:07

At 12/12/12 06:29 PM, eatmeatleet wrote:
autism at it's best

You sir was corrected. Moar stuff...

What comes around goes around...

Kajenx
Kajenx
• Member since: Dec. 1, 2006
• Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Music represented through logic? 2012-12-15 00:35:31

Haha, you guys wouldn't have survived writing for video games in the early days. Isn't this how they had to do it?