Friday, 28 October 2011

Some deep analysis of one-line music programs.

It is now a month since I posted the YouTube video "Experimental music from very short C programs" and three weeks since I blogged about it. Now that the initial craze seems to be over, it's a good time to look back what has been done and consider what could be done in the future.

The developments since my last post can be summarized by my third video. It still represents the current state of the art quite well and includes a good variety of different types of formulas.


The videos only show off a portion of all the formulas that could be included. To compensate, I've created a text file where I've collected all the "worthy" formulas I've encountered so far. Most of them can be tested in the on-line JavaScript and ActionScript test tools. Some of them don't even work directly in C code, as they depend on JS/AS-specific features.

As I'm sure that many people still find these formulas rather magical and mysterious, I've decided to give you a detailed technical analysis and explanation on the essential techniques. As I'm completely self-educated in music theory, please pardon my notation and terminology that may be unorthodox at times. You should also have a grasp of C-like expression syntax and binary arithmetic to understand most of the things I'm going to talk about.

I've sorted my formula collection by length. By comparing the shortest and longest formulas, it is apparent that the longest formulas show a much more constructivist approach, including musical data stored in constants as well as entire piece-by-piece-constructed softsynths. The shortest formulas, on the other hand, are very often discovered via non-deterministic testing, from educated guesses to pure trial-and-error. One of my aims with this essay is to bring some understanding and determinism to the short side as well.

Pitches and scales

A class of formulas that is quite prominent among the shortest ones is what I call the 't* class'. The formulas of this type multiply the time counter t with some expression, resulting in a sawtooth wave that changes its pitch according to that expression.

A simple example of a t*-class formula would be t*(t>>10) which outputs a rising and falling sound (accompanied by some aliasing artifacts that create their own sounds). Now, if we introduce an AND operator to this formula, we can restrict the set of pitches and thus create melodies. An example that has been individually discovered by several people, is the so-called "Forty-Two Melody": t*(42&t>>10) or t*2*(21&t>>11).

The numbers that indicate pitches are not semitones or anything like that, but multiplies of a base frequency (sampling rate divided by 256, i.e. 31.25 Hz at the default 8 kHz rate). Here is a table that maps the integer pitches 1..31 to cents and Western note names. The pitches on a gray background don't have good counterparts in the traditional Western system, so I've used quarter-tone flat and sharp symbols to give them approximate names.


By using this table, we can decode the Forty-Two Melody into a human-readable form. The melody is 32 steps long and consists of eight unique pitch multipliers (including zero which gives out silence).


The "Forty-Two Melody" contains some intervals that make it sound a little bit silly, detuned or "Arabic" to Western ears. If we want to avoid this effect, we need to design our formulas so that they only yield pitches that are at familiar intervals from one another. A simple solution is to include a modulo operator to wrap larger numbers to the range where simple integer ratios are more probable. Modifying the Forty-Two Melody into t*((42&t>>10)%14), for example, completely transforms the latter half of the melody into something that sounds a little bit nicer to Western ears. Bitwise AND is also useful for limiting the pitch set to a specific scale; for example t*(5+((t>>11)&5)) produces pitch multipliers of 4, 5, 8 and 9, which correspond to E3, G3, C4 and D4.

Ryg's 44.1 kHz formula presented in the third video contains two different melody generators:

((t*("36364689"[t>>13&7]&15))/12&128)
+(((((t>>12)^(t>>12)-2)%11*t)/4|t>>13)&127)

The first generator, in the first half of the formula, is based on a string constant that contains a straight-forward list of pitches. This list is used for the bass pattern. The other generator, whose core is the subexpression ((t>>12)^(t>>12)-2)%11, is more interesting, as it generates a rather deep self-similar melody structure with just three operators (subtraction, exclusive or, modulo). Rather impressive despite its profound repetitiveness. Here's an analysis of the series it generates:

It is often a good idea to post-process the waveform output of a plain t* formula. The sawtooth wave tends to produce a lot of aliasing artifacts, particularly at low sampling rates. Attaching a '&128' or '&64' in the end of a t* formula switches the output to square wave which usually sounds a little bit cleaner. An example of this would be Niklas Roy's t*(t>>9|t>>13)&16 which sounds a lot noisier without the AND (although most of the noise in this case comes from the unbounded multiplication arithmetic, not from aliasing).

Bitwise waveforms and harmonies

Another class of formulas that is very prominent among the short ones is the bitwise formula. At its purest, such a formula only uses bitwise operations (shifts, negation, AND, OR, XOR) combined with constants and t. A simple example is t&t>>8 -- the "Sierpinski Harmony". Sierpinski triangles appear very often in plotted visualizations of bitwise waveforms, and t&t>>8 represents the simplest type of formula that renders into a nice Sierpinski triangle.

Bitwise formulas often sound surprisingly multitonal for their length. This is based on the fact that an 8-bit sawtooth wave can be thought of consisting of eight square waves, each an octave apart from its neighbor. Usually, these components fuse together in the human brain, forming the harmonics of a single timbre, but if we turn them on and off a couple of times per second or slower, the brain might perceive them as separate tones. For example, t&48 sounds quite monotonal, but in t&48&t>>8, the exactly same waveform sounds bitonal because it abruptly extends the harmonic content of the previous waveform.

The loudest of the eight square-wave components of an 8-bit wave is, naturally, the one represented by the most significant bit (&128). In the sawtooth wave, it is also the longest in wavelength. The second highest bit (&64) represents a square wave that has half the wavelength and amplitude, the third highest halves the parameters once more, and so on. By using this principle, we can analyze the musical structure of the Sierpinski Harmony:


The introduction of ever lower square-wave components can be easily heard. One can also hear quite well that every newly introduced component is considerably lower in pitch than the previous one. However, if we include a prime multiplier in the Sierpinski Harmony, we will encounter an anomaly. In (t*3)&t>>8, the loudest tone actually goes higher at a specific point (and the interval isn't an octave either).

This phenomenon can be explained with aliasing artifacts and how they are processed by the brain. The main wavelength in t*3 is not constant but alternates between two values, 42 and 43, averaging to 42.67 (256/3). The human mind interprets this kind of sound as a waveform of the average length (42.67 samples) accompanied by an extra sound that represents the "error" (or the difference from the ideal wave). In the t*3 example, this extra sound has a period of 256 samples and sounds like a buzzer when listened separately.

The smaller the wavelengths we are dealing with are, the more prominent these aliasing artifacts become, eventually dominating over their parent waveforms. By listening to (t*3)&128, (t*3)&64 and (t*3)&32, we notice an interval of an octave between them. However, when we step over from (t*3)&32 to (t*3)&16, the interval is definitely not an octave. This is the threshold where the artifact wave becomes dominant. This is why t&t>>8, (t*3)&t>>8 and (t*5)&t>>8 sound so different. It is also the reason why high-pitched melodies may sound very detuned.

Variants of the Sierpinski harmony can be combined to produce melodies. Examples of this approach include:

t*5&(t>>7)|t*3&(t*4>>10) (from miiro)

(t*5&t>>7)|(t*3&t>>10) (from viznut)

t*9&t>>4|t*5&t>>7|t*3&t/1024 (from stephth)

Different counters are the driving force of bitwise formulas. At their simplest, counters are just bitshifted versions of the main counter (t). These are implicitly synchronized with each other and work on different temporal levels of the musical piece. However, it has also been fruitful to experiment with counters that don't have a simple common denominator, and even with ones whose speeds are nearly identical. For example, t&t%255 brings a 256-cycle counter and a 255-cycle counter together with an AND operation, resulting in an ambient drone sound that sounds like something achievable with pulse-width modulation. This approach seems to be more useful for loosely structured soundscapes than clear-cut rhythms or melodies.

Some oneliner songs attach a bitwise operation to a melody generator for transposing the output by whole octaves. A simple example is Rrrola's t*(0xCA98>>(t>>9&14)&15)|t>>8 which would just loop a simple series of notes without the trailing '|t>>8'. This part gradually fixes the upper bits of the output to 1s, effectively raising the pitch of the melody and fading its volume out. Also the formulas from Ryg and Kb in my third video use this technique. The most advanced use of it I've seen so far, however, is in Mu6k's song (the last one in the 3rd video) which synthesizes its lead melody (along with some accompanying beeps) by taking the bassline and selectively turning its bits on and off. This takes place within the subexpression (t>>8^t>>10|t>>14|x)&63 where the waveform of the bass is input as x.

Modular wrap-arounds and other synthesis techniques

All the examples presented so far only use counters and bitwise operations to synthesize the actual waveforms. It's therefore necessary to talk a little bit about other operations and their potential as well.

By accompanying a bitwise formula with a simple addition or substraction, it is possible to create modular wrap-around artifacts that produce totally different sounds. Tiny, nearly inaudible sounds may become very dominant. Harmonious sounds often become noisy and percussive. By extending the short Sierpinski harmony t&t>>4 into (t&t>>4)-5, something that sounds like an "8-bit" drum appears on top of it. The same principle can also be applied to more complex Sierpinski harmony derivatives as well as other bitwise formulas:

(t*9&t>>4|t*5&t>>7|t*3&t/1024)-1

I'm not going into a deep analysis of how modular wrap-arounds affect the harmonic structure of a sound, as I guess someone has already done the math before. However, modular addition can be used for something that sounds like oscillator hard-sync in analog synthesizers, although its technical basis is different.

Perhaps the most obvious use for summing in a softsynth, however, is the one where modular wrap-around is not very useful: mixing of several sound sources together. A straight-forward recipe for this is (A&127)+(B&127), which may be a little long-winded when aiming at minimalism. Often, just a simple XOR operation is enough to replace it, although it usually produces artifacts that may sound good or bad depending on the case. XOR can also be used for effects that sound like hard-sync.

Of course, modular wrap-around effects are also achievable with multiplication and division, and on the other hand, even without addition or subtraction. I'll illustrate this with just a couple of interesting-sounding examples:

t>>4|t&((t>>5)/(t>>7-(t>>15)&-t>>7-(t>>15))) (from droid, js/as only)

(int)(t/1e7*t*t+t)%127|t>>4|t>>5|t%127+(t>>16)|t (from bst)

t>>6&1?t>>5:-t>>4 (from droid)

There's a lot in these and other synthesis algorithms that could be discussed, but as they already belong to a zone where traditional sound synthesis lore applies, I choose to go on.

Deterministic composition

When looking at the longest formulas in the collection, it is apparent that there's a lot of intelligent design behind most of them. Long constants and tables, sometimes several of them, containing scales, melodies, basslines and drum patterns. The longest formula in the collection is "Long Line Theory", a cover of the soundtrack of the 64K demo "Chaos Theory" by Conspiracy. The original version by mu6k was over 600 characters long, from which the people on Pouet.net optimized it down to 300 characters, with some arguable quality tradeoffs.

It is, of course, possible to synthesize just about anything with a formula, especially if there's no upper limit for the length. Synthesis and sequencing logic can be built section by section, using rather generic algorithms and proven engineering techniques. There's no magic in it. But on the other hand, there's no magic in pure non-determinism either: it is very difficult to find anything outstanding with totally random experimentation after the initial discovery phase is over.

Many of the more sophisticated formulas seem to have a good balance between random experimentation and deterministic composition. It is often apparent in their structure that some elements are results of random discoveries while others have been built with an engineer's mindset. Let's look at Mu6k's song (presented in the end of the 3rd video, 32 kHz):

(((int)(3e3/(y=t&16383))&1)*35) +
(x=t*("6689"[t>>16&3]&15)/24&127)*y/4e4 +
((t>>8^t>>10|t>>14|x)&63)

I've split the formula on three lines according to the three instruments therein: drum, bass and lead.

My assumption is that the song has been built around the lead formula that was discovered first, probably in the form of t>>6^t>>8|t>>12|t&63 or something (the original version of this formula ran at 8 kHz). As usual with pure bitwise formulas, all the intervals are octaves, but in this case, the musical structure is very nice.

As it is possible to transpose a bit-masking melody simply by transposing the carrier wave, it's a good idea to generate a bassline and reuse it as the carrier. Unlike the lead generator, the bassline generator is very straight-forward in appearance, consisting of four pitch values stored in a string constant. A sawtooth wave is generated, stored to a variable (so that it can be reused by the lead melody generator) and amplitude-modulated.

Finally, there's a simple drum beat that is generated by a combination of division and bit extraction. The extracted bit is scaled to the amplitude of 35. Simple drums are often synthesized by using fast downward pitch-slides and the division approach does this very well.

In the case of Ryg's formula I discussed some sections earlier, I might also guess that the melody generator, the most chaotic element of the system, was the central piece which was later coupled with a bassline generator whose pitches were deliberately chosen to harmonize with the generated melody.

The future

I have been contacted by quite many people who have brought up different ideas of future development. We should, for example, have a social website where anyone could enter new formulas, listen to the in a playlist-like manner and rate them. Another branch of ideas is about the production of new rateable formulas by random generation or by breeding old ones together with genetic algorithms.

All of these ideas are definitely interesting, but I don't think the time is yet right for them. I have been developing my audiovisual virtual machine, which is the main reason why I did these experiments in the first place. I regard the current concept of "oneliner music" as a mere placeholder for the system that is yet to be released. There are too many problems with the C-like infix syntax and other aspects of the concept, so I think it's wiser to first develop a better toy and then think about a community mechanism. However, these are just my own priorities. If someone feels like building the kind of on-line community I described, I'll support the idea.

I've mentioned this toy before. It was previously called EDAM, but now I've chosen to name it IBNIZ (Ideally Bare Numeric Impression giZmo). One of the I letters could also stand for "immediate" or "interactive", as I'm going to emphasize an immediate, hands-on modifiability of the code. IBNIZ will hopefully be relevant as a demoscene platform for extreme size classes, as a test bed for esoteric algorithmic trickery, as an appealing introduction to hard-core minimalist programming, and also as a fun toy to just jam around with. Here's a little screenshot of the current state:


In my previous post, I mentioned the possibility of opening a door for 256-byte demos that are interesting both graphically and musically. The oneliner music project and IBNIZ will provide valuable research for the high-level, algorithmic aspects of this project, but I've also made some
hands-on tests on the platform-level feasability of the idea. It is now apparent that a stand-alone MS-DOS program that generates PCM sound and synchronized real-time graphics can easily fit in less then 96 bytes, so there's a lot of room left for both music and graphics in the 256-byte size
class. I'll probably release a 128- or 256-byte demo as a proof-of-concept, utilizing something derived from a nice oneliner music formula as the soundtrack.

I would like to thank everyone who has been interested in the oneliner music project, as all the hype made me very determined to continue my quests for unleashing the potential of the bit and the byte. My next post regarding this quest will probably appear once there's a version of IBNIZ worth releasing to the public.

436 comments:

«Oldest   ‹Older   401 – 436 of 436
mike penns said...

Great blog you have here thanks.sphynx-cat-for-salethanks for sharingsphynx-cat-for-sale-ohio

SOFTWARE COMPANY said...

a fantastic article Thank you for sharing. Everyone seeking a software agency should read this post.
Brisk logic is a Mohali-based software design, app development, and web design firm.
digital transformation and business automation

โรซ่า said...

Hello, we have a game to recommend.

รีวิวเครื่องสำอาง
สูตรบาคาร่า
บอล
เลขเด็ด
jili-เว็บตรง

Thank you for your interest."

Unknown said...

Sales Apps

Captions said...

We really like your services. And we have benefited a lot. Thank you so much for helping us with this kind of service.

Scopex said...

Service Apps

Mani said...

Thank you for sharing this article. The information you've supplied is superior to that of another blog.

SEO in Chennai

Mani said...

PVC Blister Manufacturer in Chennai
Building Construction in Chennai
Best Building Contractors in Chennai
2d Plan Services in Chennai
CCTV Dealers in Chennai
Best Wedding Photographer in Chennai

Quickbooks Support Service said...

One such service is to call the toll-free number +1 888-698-6548, on weekdays from 9:00am to 6:00pm PST. For more questions, you can also contact them via their website at Quickbooks Customer Service.

Jai Jaiswal said...

Thanks for sharing Supper blog. My website for best yogainfo any types yoga information and update yoga news. Yoga, yogainfo , Female fitness, you reach us at

unogeeks said...

This is really interesting, you are such a great blogger. UnoGeeks Offers the best Salesforce Training in the market today. If you want to become Expert in Salesforce, Enrol in the Salesforce Training offered by UnoGeeks

Premium Learnings said...

Get your Career in IT on track with our Career Accelerator Program by Premium Learnings

Check our Youtube channel for our training videos - https://www.youtube.com/c/PremiumLearningssystem

For more info do visit us: https://www.premiumlearnings.com/

Online Shopping in Pakistan said...

Thank you very much for sharing this fantastic article.

samsung mobile on installment
road prince bike price in Pakistan
iphone 13 on installments


Tonuriapelgratuite said...
This comment has been removed by the author.
Tonuriapelgratuite said...

Looking for a way to add some quick and easy music to your program? Look no further than one-line music programs! These programs are simple, but they can produce some great results. We'll take a look at some of the best one-line music programs out there.

There's something about one-line music programs that just makes them so intriguing. It's like they're little worlds all unto themselves, and you can get lost in them for hours on end. I'll explore some of the deep analysis you can do with just a single line of music code. With a little bit of exploration, you can create intricate and beautiful pieces of music with just a few simple lines of code.

I was reading an article the other day about musician, Brian Eno, and his one-line music programs. I was fascinated by the simplicity of these programs and how they produce complex sounds. I decided to do some of my own research into one-line music programs and what I found was really interesting. I'll discuss some of the simpler one-line music programs and how they work. Stay tuned for more in-depth analysis of more complex one-line music programs in future posts!
Or more simply, please refer to some wonderful music at: https://tonurideapelgratuite.com/

UnoGeeks said...

Thank you for sharing such a nice and interesting blog and really very helpful article. Mulesoft is the Most Widely Used Integration Platform. If you want to become Mulesoft Certified Developer, attend this Best Mulesoft Training Course offered by the Unogeeks (Top Mulesoft Training Institute)

Media Foster said...

Media Foster is the best provider of Digital marketing services in Mohali.We are known for providing the best quality digital services in Mohali and its neighborhood.
best IT company in Mohali
digital marketing course in Mohali

veerediwedding said...

We have give best luxury car rental Services since long periods of experience in offering top luxury cars with top class chauffeur. if you need more information visit our website.
luxury car rental in Amritsar
luxury wedding cars in Chandigarh

BIGSTAR V2SERVICES said...

Bigstar V2services Private Ltd is a well-known company that provides Security Services in Bangalore at a reasonable cost to its valued customers. We work with reputable multinational corporations, businesses, industries, banks, warehouses, flats, bungalows, showrooms, and hotels to provide security services. Our security experts are well-trained and dedicated at the time of need to defend our clients' property.

UnoGeeks said...

Want to become Oracle Fusion SCM Certified Consultant? Attend this Best Oracle Fusion SCM Online Training offered by the Unogeeks, Top Oracle Fusion SCM Online Training Institute in the market

sasikala said...

nice post. thanks for sharing....
CNC Programming Course in Coimbatore
best CNC Programming Course in Coimbatore
CNC Programming training Course in Coimbatore
CNC Programming training institute in Coimbatore
best CNC Programming training institute in Coimbatore
CNC Programming training in Coimbatore
best CNC Programming training in Coimbatore
CNC Programming training institute in Coimbatore with placement
CNC Programming Course fees in Coimbatore
CNC Programming Coching centre in Coimbatore

Accounting Service said...

This is beneficial Information for me Thanks For Sharing Such as Information .Kindly Go Through QuickBooks Support Phone Number +1 866-448-6293 For any Best QuickBooks Customer Service

Anonymous said...

• جایی که بانک‌ها خرید و فروش می‌کنند را به‌صورت دقیق مشخص کنید.
• قبل از اینکه روندهای بازگشتی شروع شوند، وارد بازار شوید.
در سال‌های اخیر معامله‌گری بر اساس عرضه و تقاضا به یکی از رایج‌ترین استراتژی‌های معامله‌گری در بازار فارکس تبدیل شده است؛ زیرا معامله‌گری بر این اساس، به شما امکان می‌دهد که قبل از آغاز روندهای بازگشتی، بزرگ‌ترین روندهای بازگشتی را شروع کنید و وارد آن‌ها شوید.

Sunny said...

Amazing post thanks for sharing the post. Your blogs are admirable and full of knowledge Embedded Systems Course in Hyderabad

Denkpopo said...

orphanage home near me

Kary Christ said...

cpap machine rental

lakshmi said...

Extremely intriguing site. Many websites I see these days don't actually give whatever draws in others, however accept me the manner in which you cooperate is in a real sense wonderful. You can really look at my articles too.
visit us: -swhizz
our services: -
Salesforce
DevOps
aws
Testing
Java

Rate Trade said...

Find the best-fixed mortgage rate in London that works perfectly for you. We make it easy to compare rates in London big banks and top brokers for free. Best mortgage rate in London

DAVE said...

I really want to thank you for your time of this splendid read!!! I obviously value every single piece of it and I have you bookmarked to take a gander at new stuff of your blog a flat out need read the blog!
https://martinaonp199.postach.io/post/how-to-explain-facebook-marketing-courses-to-your-boss

uday said...

Nice thanks for sharing informative post like this keep posting if like more details visit my website linkhttps://azuretrainings.in/azure-devops/

free news said...

Nice article we really like this status video in one click and if you like this then share them netflix

Admin said...

Nice article we like this mod apk and then share this girlsdp in one click

sanu rajak said...

Oh This blog was wonderful we really appreciate that click for more info

mobile crm software said...

mobile crm apps
buy crm

srislawvicky said...

Wonderful blog and keep posting
local family lawyers
Abogados Divorcio Culpeper VA
Abogados Divorcio Spotsylvania VA

Anonymous said...

Bulk Fresh Fullz/Pros/Leads Available

High Credit Scores Fullz 700+
CC Fullz (USA/UK/CANADA)
SSN DOB DL Fullz
Office365 Leads
Dumps With Pin
Business EIN Fullz
Leads for Tax Return/PUA USA

ICQ/TG - @killhacks
WA - +92 317 2721122
Email- exploit dot tools4u at gmail dot com

All Spamming & Hacking Tools
Carding Methods/Loan Methods
Mailers/Senders/Shells/Brutes
C-panels/RDP's/SMTP's
Onion Web Links
I.p's/Proxies/Server I.P's
Combos/Premium account Logs
Fr**d B**le 201/2022/2023 Updated

ICQ- 752822040
Telegram - @killhacks

«Oldest ‹Older   401 – 436 of 436   Newer› Newest»