I gave a fruit fly a strange new job: compose music.
I wanted to see what would happen if a real fruit fly connectome was put to work inside a music-making system. Instead of simply turning neural activity into random clicks and beeps, I wanted to see if the fly could actually participate in the process of creating something musical.
So I gave it musical knowledge, gave it room to make decisions, and let it start working.
It generated ideas. It explored different musical possibilities. Some ideas worked better than others. The weaker ones were discarded while stronger ones continued to develop.
Eventually, some pieces of music emerged. Of course they are not club-ready songs but they prove that this method actually works.
The fly learns from its creations and evolves with each song. So future songs should be better. Also I could use some other music creation libraries and create actually listenable decent music, but thats not the point of this experiment.
So how does a fruit fly end up composing music in the first place?
What I did is build a computational music system around a real reconstructed FlyWire connectome and gave that biological neural network a role in the composition process using Python. I used libraries like fafbseg, caveclient, numpy, scipy, and music21. The musical knowledge, rules, evaluation, and rendering all came from the surrounding software i coded myself.
It took a full week, over 2,500 lines of Python code, eight hours of heavy training, and hundreds of trial-and-error runs to get here.
1. Why I Asked a Fruit Fly Brain to Make Music
There is something strangely fascinating about giving a tiny fruit fly a job it was never evolved to do.
A fruit fly does not need to write melodies. It does not need to understand chords. It does not need to keep a beat or decide whether one musical phrase works better than another.
And yet, once its reconstructed neural wiring is represented inside a computer, we can put that neural system into situations that have nothing to do with the original animal.
That made me wonder: what would happen if I asked it to make music?
Music seemed like an especially interesting challenge because producing sound is easy. Producing something that resembles music is much harder.
A musical idea can depend on rhythm, pitch, harmony, repetition, variation, tension, timing, and structure. A few random notes can make noise, but a sequence of notes with relationships between them can start to sound like an actual musical idea.
I wanted to see what the fly would do with that problem.
From Strange Fly-Brain Experiments to Music
Recently, reconstructed fruit fly nervous systems have been used in computational experiments involving things they were never designed to control. Games, simulations, control systems, and other unusual applications have shown that a biological connectome can be placed inside a very different computational environment.
That got me thinking about music.
If a fruit fly's neural wiring can participate in controlling something, could it also participate in creating something?
Could the fly make a melody?
Could it develop a rhythm?
Could it choose between different musical possibilities?
And could the result sound like more than random noise?
I didn't want to answer those questions by simply converting neural spikes into audio. That would produce a direct mapping between neural activity and sound, but it wouldn't really be a music-making system.
I wanted to give the fly something to work with.
So instead of starting with an empty system, I gave it access to musical knowledge: rhythm, pitch, harmony, intervals, melodies, phrases, and structure.
Then I let the neural processing become part of what happened next.
The Idea Behind the Experiment
The basic idea is easier to understand than the implementation.
Imagine the fly sitting in front of a musical problem.
It has possibilities in front of it. Different notes can follow one another. Rhythms can change. Melodies can develop. Chords can create different harmonic directions.
The fly has to somehow navigate those possibilities.
Except that this is where the story starts to change.
The fly does not actually understand any of those musical concepts.
The real system works differently.
The FlyWire connectome provides the neural substrate. The musical knowledge comes from the software surrounding it. That software gives the system information about musical patterns and relationships, while the connectome provides neural processing that can influence the decisions being made.
So when I say that the fly made a musical decision, I am describing what the complete system did through the role assigned to the fly's neural substrate.
I am not claiming that a biological fruit fly suddenly learned music theory and started composing songs inside its tiny head.
I built a computational system around a real reconstructed fruit fly connectome and gave that system musical knowledge.
That distinction is important, but it doesn't make the experiment less interesting.
In fact, it makes the question more interesting.
I wasn't asking a fly to invent thousands of years of music theory from nothing. I was giving the system the kind of musical foundation that any useful composition system needs: existing patterns, relationships, and knowledge.
Then I could let the neural processing influence what happened next.
The goal was not simply to make a fly produce sound.
The goal was to find out what happens when a real biological connectome becomes part of a system that can produce something recognizably musical.
2. Giving a Fly Brain Musical Knowledge
Now that I had given the fly a musical job, it needed something to work with.
A neural network does not automatically know what a melody, chord, rhythm, or musical phrase is. If I simply gave the fly a blank system and asked it to compose, there would be no reason to expect anything resembling music.
So I gave it musical knowledge.
The idea was simple: let the fly work with patterns that already exist in music, then see what happens when its neural processing becomes part of the process.
Using a Real FlyWire Connectome
The first part of the experiment was the fly itself.
I didn't create a random neural network and pretend it was a fruit fly. I used a real connectome from FlyWire. The system is based on the FAFB v783 dataset and works with a sparse network containing 8,192 neurons and their recorded synaptic connections.
So the fly's neural wiring was not invented for the experiment. It came from an actual reconstructed biological nervous system.
But there was an obvious problem.
The connectome is a map of biological wiring. It tells the computer which neurons are connected and how those connections are organized. It doesn't come with an understanding of music.
The fly didn't know what a chord was.
It didn't know what a melody was.
It didn't know that one rhythm might work better than another.
That knowledge had to come from somewhere else.
The connectome provided the neural substrate. The musical knowledge had to be learned separately.
Teaching the System How Music Works
I didn't want to tell the fly, "Here are some notes. Now make something."
Instead, I gave the composer musical material from which it could learn actual patterns and relationships.
Its musical memory keeps track of things such as pitch, intervals, note durations, rhythm, velocity, tempo, keys, chords, and recurring patterns. It can also learn relationships between these elements, including rhythmic patterns, interval sequences, chord patterns, motifs, and genre-specific characteristics.
To build that musical vocabulary, I fed the system two specific datasets:
- MAESTRO (v3.0.0): A massive 101GB dataset (120GB uncompressed) containing 2,552 aligned MIDI and WAV files, covering roughly 200 hours of virtuosic, high-precision piano performances. This gave the system a deep foundation in complex harmonic progressions, melodic phrasing, velocity, and dynamic expression.
- Groove MIDI (v1.0.0): A 4.76GB package containing 1,150 files across about 13.6 hours of human-performed drum patterns. This supplied the realistic rhythmic feel, micro-timing nuances, and genre-specific grooves.
This gives the system something much more useful than a collection of isolated notes.
It gives it an actual musical language.
For example, a melody is not simply a sequence of randomly selected pitches. The distance between notes matters. Rhythm matters. The relationship between a melody and its harmony matters. By pairing MAESTRO’s heavy harmonic depth with Groove MIDI’s expressive timing, the system learns how a musical phrase naturally develops over time from real human examples.
So while the fly provides the neural machinery, this musical knowledge gives the system something meaningful to process.
The composition system has a grounded representation of chords, melodies, rhythms, and phrases. What I wanted to find out was what would happen when all that learned musical context was put together with the activity of a real biological connectome.
Letting Neural Processing Work With Musical Knowledge
This is where the experiment starts to get interesting.
I am not simply mapping every neuron to a note and waiting for the resulting noise to become a song. The FlyWire network is one component of a much larger composition system.
The musical knowledge gives the fly meaningful possibilities to work with.
The FlyWire network provides another layer of neural processing that can influence musical decisions.
The system can then evaluate those decisions and continue developing the stronger ideas.
In other words, the two sides have different jobs.
The learned musical knowledge tells the system what musical possibilities look like. The connectome provides the neural substrate through which neural activity can influence which possibilities are explored, selected, and developed.
This also means I am not expecting the fly to independently rediscover thousands of years of music theory.
That would be the wrong experiment.
A human musician doesn't create music from a completely empty state either. We absorb musical patterns, develop preferences, recognize relationships, and work with an enormous amount of existing musical knowledge.
My approach is similar in principle: give the computational system musical knowledge first, then let a real biological connectome become part of the creative process.
So the fly doesn't have to invent the language of music.
It gets to work with a language that already exists.
The interesting question is what it does with it.
Can neural processing from a biological connectome meaningfully influence the construction of music?
That was what I wanted to find out.
3. How the FlyWire Composer Makes Music
This is where I let the fly actually start composing.
It didn't simply produce one sequence of notes and stop. It explored musical possibilities, made decisions, tested the results, and kept developing the ideas that worked better.
At least, that's what it looked like from the outside.
Underneath that behavior was a much larger system. The FlyWire network was influencing the process, while the musical knowledge, composition machinery, evaluation, and evolutionary search gave the system a way to turn that influence into increasingly structured musical ideas.
+-----------------------------------------------------------------------------------+
| 1. INPUT SOURCES |
| +-------------------------------------+ +-----------------------------------+ |
| | FlyWire Connectome (FAFB v783) | | Musical Vocabulary Corpora | |
| | • 8,192 Subsampled Neurons | | • MAESTRO v3.0.0 (Piano/Harmony) | |
| | • Synaptic Connection Graph | | • Groove MIDI v1.0.0 (Drums/Rhythm)| |
| +------------------+------------------+ +-----------------+-----------------+ |
+---------------------|----------------------------------------|--------------------+
| |
+-------------------+--------------------+
|
v
+-----------------------------------------------------------------------------------+
| 2. CANDIDATE GENERATOR |
| • Neural activity triggers stochastic exploration of musical possibilities |
| • Generates population of candidate MIDI motifs, phrases, & chord progressions |
+-----------------------------------------+-----------------------------------------+
|
v
+-----------------------------------------------------------------------------------+
| 3. EVALUATION (THE CRITIC) |
| • Multi-Dimensional Scoring: |
| - Harmony & Voice Leading - Rhythm Coherence - Tension & Novelty |
+-----------------------------------------+-----------------------------------------+
|
v
+-----------------------------------------------------------------------------------+
| 4. EVOLUTIONARY LOOP |
| • Discards low-scoring noise --> Mutates & preserves top candidates |
+-----------------------------------------+-----------------------------------------+
|
v
+-----------------------------------------------------------------------------------+
| 5. RENDERING & OUTPUT |
| • Selected candidate structure rendered to final MIDI & WAV audio files |
+-----------------------------------------------------------------------------------+
From Neural Activity to Musical Decisions
Once the fly had its musical knowledge and its neural network was active, it could start making composition decisions.
The FlyWire network is represented as a directed neural graph. In the real FlyWire dataset, neurons are connected through synapses, creating a huge network of biological wiring. My composer uses a selected 8,192-neuron portion of that network rather than attempting to simulate the entire connectome.
The interesting part is what happens when this network becomes active.
Neural activity becomes another source of information inside the composition process. It can influence how musical possibilities are explored and selected, while the learned musical knowledge provides the patterns and relationships that keep those possibilities musically meaningful.
So the fly isn't simply choosing notes from an enormous random list.
It is operating inside a musical environment where there are already possibilities, relationships, and constraints.
The result is not a literal translation of individual neurons into individual notes. One neuron does not equal one note, and a spike does not simply become a sound.
Instead, the connectome acts as a computational substrate inside the composer.
The fly's neural activity becomes part of the process through which musical possibilities are explored.
The Critic: Evaluating Musical Quality
Generating a bunch of notes is easy; knowing which ones actually sound good is the hard part. That’s where the Critic comes in.
The Critic is the software module responsible for judging every musical candidate the fly-influenced system creates. Instead of letting the network output raw, unfiltered randomness, the Critic acts as an automated scoring engine, evaluating ideas across several specific dimensions:
Harmony & Voice Leading: Checking if chord transitions make sense and if individual melodic lines move smoothly.
Rhythm & Phrasing: Ensuring the music maintains a coherent beat, pulse, and structural shape rather than falling into erratic timing.
Tension & Novelty: Balancing predictable, satisfying patterns with enough contrast and surprise to keep things interesting.
Style & Form: Measuring how well the composition aligns with the structural rules and relationships learned from the training data.
Without the Critic, the evolutionary process wouldn't know which direction to push. By assigning every candidate idea a clear score, it gives the system the feedback loop it needs—discarding the weak ideas, retaining the strong ones, and guiding the connectome's neural activity toward genuine music.
Generating, Evaluating, and Refining Music
The fly doesn't get just one chance to make a song.
The composer creates multiple musical candidates and evaluates them. The evaluation considers several aspects of the composition, including harmony, melody, rhythm, phrasing, form, style, novelty, tension, voice leading, and how well the result fits the learned musical material.
Some ideas work better than others.
The stronger candidates survive.
The weaker ones are discarded.
Then the process starts again.
Candidates are generated, evaluated, and refined over multiple generations. Stronger candidates are retained while new variations are explored. The FlyWire system becomes part of this larger decision-making process rather than being treated as the entire composition algorithm.
This is where the experiment starts to look less like a random neural experiment and more like an actual composer at work.
Music is not just about generating enough sounds.
A note needs context. A rhythm needs a pulse. A chord needs a relationship to what came before and what comes next. A phrase needs some sense of direction. Even something deliberately simple can sound completely different depending on how these elements interact.
The composer therefore gives the fly a structured musical environment to work inside.
The musical knowledge provides the possibilities. The neural processing influences the exploration. The evaluation system determines which ideas are worth developing. The evolutionary process keeps pushing the composition toward stronger results.
The fly doesn't have to solve every part of music by itself.
It has to participate in the process.
Turning the Result Into a Finished Track
Eventually, one composition survives the generation and refinement process as the selected result.
Now the fly has something to show for its work.
The system turns the resulting musical structure into an actual MIDI composition and renders it as audio. What began as neural activity, musical patterns, and competing candidates becomes something you can finally listen to.
But the final track is not the output of one component.
The FlyWire network contributes its neural processing. The learned musical memory provides patterns and relationships. The composition system generates possibilities. The critic evaluates them. The evolutionary process refines them. Finally, the resulting musical structure is rendered into a playable track.
And this is where the story gets a little strange.
I can say that the fly composed the track.
I can describe it as the fly exploring musical ideas, making decisions, rejecting some possibilities, and developing others.
But there was never a tiny musician inside the computer actually listening to its own composition.
The "fly" was a real reconstructed biological connectome operating inside a much larger computational system.
And that distinction turns out to be the most interesting part of the experiment.
4. What Does It Mean for a Fly Brain to Make Music?
By this point, the fly has made music.
Or at least, that's how the experiment looks from the outside.
It explored musical possibilities, influenced decisions, survived the selection process, and eventually became part of a system that produced a finished track.
But now we have to ask a more difficult question:
How much of that music actually came from the fly?
This is where the experiment becomes more complicated than the headline suggests.
The answer is not that a fruit fly suddenly became a musician. There was no tiny composer inside the computer consciously thinking about melodies or deciding which chord sounded better.
What actually happened is more interesting: a real biological connectome was placed inside a computational system that already had the knowledge and machinery needed to make music.
What Comes From the Fly and What Comes From the Code
At this point, there is an important question to answer: how much of the music actually comes from the fly?
The honest answer is that it is not possible to separate the final composition into a simple percentage of "fly" and "code."
The FlyWire connectome provides the neural substrate. Its structure and activity come from biological data reconstructed from a fruit fly nervous system.
Everything around that connectome is software.
The software provides the musical knowledge, composition rules, memory, evaluation, candidate generation, evolutionary refinement, and the machinery required to turn the resulting structure into music.
Without that software, the connectome does not suddenly understand chords, melodies, rhythm, or musical form.
And without the connectome, this particular experiment would not be the same experiment.
That is why it is more accurate to think of the result as an interaction between a biological neural substrate and an engineered musical system.
The fly is not secretly sitting inside the computer writing a song.
But its reconstructed neural wiring is genuinely part of the system making the decisions.
That distinction might sound like a technical detail, but it is actually the most interesting part of the experiment.
Can a Biological Connectome Become a Creative Substrate?
So, did I prove that a fruit fly can compose music?
No.
That would be a much bigger claim than this experiment can support.
What I demonstrated is that a reconstructed biological connectome can be incorporated into a computational music system and given a role in the process of generating and refining musical ideas.
The experiment raises a much larger question.
We normally think about artificial intelligence as something built from mathematical models designed specifically to perform a task. A biological connectome is different. It is a reconstruction of a nervous system that evolved for an entirely different purpose.
Yet once that structure is represented computationally, we can connect it to systems that were never part of the original organism.
That opens up a strange possibility.
Maybe a biological neural network does not need to understand the same world it originally evolved for in order to become useful as a computational substrate for something completely different.
Music is a particularly interesting test because it is difficult to reduce to a single rule. It involves repetition and variation, expectation and surprise, structure and timing. A system can produce technically valid notes without producing anything that feels like a coherent musical idea.
That is ultimately what I wanted to explore with the FlyWire Composer.
Not whether a tiny insect brain can magically become a musician, but whether the structure of a biological nervous system can be placed inside a creative system and actually contribute to the way that system makes decisions.
The answer, at least from this experiment, is that it can be part of the process.
And that leaves a much more interesting question for the next experiment:
If a fruit fly can participate in making music, what else can we build around it?