SlideShare a Scribd company logo
JFugue, Music, and the
Future of Java
David Koelle
@dmkoelle
Principal Software Engineer, Charles River Analytics
Side gig: Author of JFugue
play(“C”);
Sequencer sequencer = MidiSystem.getSequencer();
Sequence sequence = sequencer.getSequence();
Track track = sequence.createTrack();
ShortMessage onMessage = new ShortMessage();
onMessage.setMessage(ShortMessage.NOTE_ON, 0, 60, 128);
MidiEvent noteOnEvent = new MidiEvent(onMessage, 0);
track.add(noteOnEvent);
ShortMessage offMessage = new ShortMessage();
offMessage.setMessage(ShortMessage.NOTE_OFF, 0, 60, 128);
MidiEvent noteOffEvent = new MidiEvent(offMessage, 200);
track.add(noteOffEvent);
sequencer.start();
try {
Thread.sleep(track.ticks());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
“Hello, World!” without JFugue
import org.jfugue.player.Player;
public class HelloWorld {
public static void main(String[] args) {
Player player = new Player();
player.play(“C”);
}
}
“Hello, World!” in JFugue
public class TwelveBarBlues {
public static void main(String[] args) {
Pattern pattern = new ChordProgression(“I IV V”)
.distribute(“7%6”)
.allChordsAs(“$0 $0 $0 $0 $1 $1 $0 $0 $2 $1 $0 $0”)
.eachChordAs(“$0i $1i $2i $3i $4i $3i $2i $1i”)
.getPattern()
.setInstrument(“Acoustic Bass”)
.setTempo(120);
new Player().play(pattern);
}
}
Advanced JFugue… still fits on one slide
A Tour of the Magic of JFugue
Easy to Use
Based on Music Theory
Fun Things are Baked In
Consistent “System”
Event-Based Architecture
Five Bits of JFugue Magic
Play music with two lines of code:
Player player = new Player();
player.play(“V0 I[Flute] C3MAJw V1 I[Piano] C5q E5q G5h”);
Easy to Use
Music is easy to specify
and intentionally human-readable
C Middle-C
C#6h C# note, 6th octave, half duration
EbMAJ^w E-flat major chord, first inversion,
whole duration
Easy to Use
Music is easy to specify
and intentionally human-readable
I[Flute] Change instrument to Flute
T[Allegro] Change tempo to Allegro (120bpm)
m560.8q Play a 560.8 Hz tone at ¼-duration
Rq Rest (takes duration just like a note)
Easy to Use
Define a Scale in terms of Intervals
Define a Chord in terms of Intervals
Create a “I IV V” Chord Progression
Set the Root of a Chord Progression
Get the Chords from a Chord Progression
Get the Notes from a Chord
…
Based on Music Theory
Rhythm rhythm = new Rhythm()
.addLayer("O..oO...O..oOO..")
.addLayer("..S...S...S...S.")
.addLayer("````````````````")
.addLayer("...............+");
new Player()
.play(rhythm.getPattern().repeat(2));
Fun Things are Baked In
Pattern cp = ChordProgression
.fromChords("C#4min E4maj B3maj A3maj")
.eachChordAs("$_i $_i Ri $_i")
.getPattern()
.setInstrument("GUITAR")
.setVoice(0);
Rhythm rhythm = new Rhythm()
.addLayer("..X...X...X...XO");
new Player()
.play(new Pattern(cp, rhythm).repeat(2));
Consistent “System”
MidiParser parser = new MidiParser();
LilyPondListener listener =
new LilyPondListener();
parser.addListener(listener);
parser.parse(midi sequence);
listener.displayEngravedSheetMusic();
Event-Based Architecture
StaccatoParser parser = new StaccatoParser();
LilyPondListener listener =
new LilyPondListener();
parser.addListener(listener);
parser.parse(“C D E F G A B”);
listener.displayEngravedSheetMusic();
Event-Based Architecture
StaccatoParser parser = new StaccatoParser();
MusicXmlListener listener =
new MusicXmlListener();
parser.addListener(listener);
parser.parse(“C D E F G A B”);
listener.save(new File(“my_song.xml”));
Event-Based Architecture
MidiParser parser = new MidiParser();
MyParserListener listener = new MyParserListener();
parser.addParserListener(listener);
parser.parse(MidiSystem.getSequence(new File(“some midi file")));
System.out.println("There are "+listener.counter+" 'C' notes in this music.");
class MyParserListener extends ParserListenerAdapter {
public int counter;
@Override
public void onNoteParsed(Note note) {
if (note.getPositionInOctave() == 7) { // F# is the 7th note in an octave
counter++;
}
}
}
Event-Based Architecture
Sending to / Receiving from MIDI Devices
Creating New Patterns in Real-Time
Sending Musical Events “Before” They Occur
Extending the Staccato Parser
Using Replacement Maps to Play Solfege
Writing Functions for Musical Effects (e.g., Trill)
Scratching the Surface…
Real-World Examples
Log4JFugue: Listen to your log files!
log filesserver
video stream is created
video stream is destroyed
video stream has failed
[BASS_DRUM]s
[ACOUSTIC_SNARE]s
[CRASH_CYMBAL_1]s
audio
Winner,
2010 Duke’s
Choice Award
By Brian Tarbox http://www.Log4JFugue.org
amount of emotion
low emotion counts
high emotion counts
spikes in emotion
active:passive emotions
positive:negative emotion
amt of emotion per section
total emotions in chapter
prevalent emotions in novel
TransProse: Create Music from Literature
stability of note from root note
more consonant notes
more dissonant notes
interesting melodic movement
tempo
major/minor key and octave
note duration
main melody
additional melodies
EmoLex
By Hannah Davis http://www.MusicFromText.com
Counterpoint Composer
What is
counterpoint?
"The relationship
between voices that
are interdependent
harmonically yet
independent in
rhythm and contour"
By James Weaver http://counterpointservice.cfapps.io
JFugue & The Future of Java
Streams: Easier to generate procedural music in realtime?
Web API: Easier to build collaborative music making
experiences?
Better garbage collection: No more unexpected pauses in
generating music?
Kulla / REPL / jshell: Support LiveCoding?
Modularity: Good or bad for MIDI support?
JFugue & The Future of Java

More Related Content

PPTX
The Art, Joy, and Power of Creating Musical Programs (JFugue at SXSW Interact...
PDF
JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugue
PDF
Music is the Soul - The Web is the Platform FOWA London 2014
PDF
SecureSocial - Authentication for Play Framework
PDF
Augeas
PDF
FPBrno 2018-05-22: Benchmarking in elixir
PDF
Using New Web APIs For Your Own Pleasure – How I Wrote New Features For My Vi...
PDF
Clustering com numpy e cython
The Art, Joy, and Power of Creating Musical Programs (JFugue at SXSW Interact...
JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugue
Music is the Soul - The Web is the Platform FOWA London 2014
SecureSocial - Authentication for Play Framework
Augeas
FPBrno 2018-05-22: Benchmarking in elixir
Using New Web APIs For Your Own Pleasure – How I Wrote New Features For My Vi...
Clustering com numpy e cython

What's hot (20)

PPTX
Build a compiler in 2hrs - NCrafts Paris 2015
PDF
Ruby to Elixir - what's great and what you might miss
PDF
Go for the paranoid network programmer
PDF
Elixir & Phoenix - fast, concurrent and explicit
PDF
Music as data
PDF
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
PDF
(Fun clojure)
PDF
League of Graphs
KEY
Clojure入門
PDF
Debugging: A Senior's Skill
PDF
Finding a lost song with Node.js and async iterators - EnterJS 2021
PDF
Fewer cables
PDF
Python utan-stodhjul-motorsag
PDF
Un monde où 1 ms vaut 100 M€ - Devoxx France 2015
PDF
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
PDF
Finding a lost song with Node.js and async iterators
PDF
Hello Go
PDF
Go for the paranoid network programmer, 2nd edition
PDF
PyCon2009_AI_Alt
Build a compiler in 2hrs - NCrafts Paris 2015
Ruby to Elixir - what's great and what you might miss
Go for the paranoid network programmer
Elixir & Phoenix - fast, concurrent and explicit
Music as data
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
(Fun clojure)
League of Graphs
Clojure入門
Debugging: A Senior's Skill
Finding a lost song with Node.js and async iterators - EnterJS 2021
Fewer cables
Python utan-stodhjul-motorsag
Un monde où 1 ms vaut 100 M€ - Devoxx France 2015
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators
Hello Go
Go for the paranoid network programmer, 2nd edition
PyCon2009_AI_Alt
Ad

Similar to JFugue, Music, and the Future of Java [JavaOne 2016, CON1851] (20)

PPTX
Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."
PPTX
QA Fest 2019. Saar Rachamim. Developing Tools, While Testing
PDF
The Ring programming language version 1.6 book - Part 72 of 189
PPTX
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
PPTX
Android audio system(audio_hardwareinterace)
PDF
Pdr ppt
PDF
Transaction is a monad
PDF
Functional Thinking for Java Developers (presented in Javafest Bengaluru)
PDF
Sequencing Audio Using React and the Web Audio API
PDF
Drools5 Community Training Module 3 Drools Expert DRL Syntax
PDF
Are we ready to Go?
PDF
The Ring programming language version 1.10 book - Part 94 of 212
PDF
Network security
PPTX
ภาษาซี
PPTX
Groovy puzzlers по русски с Joker 2014
PDF
Mary Had a Little λ (QCon)
DOCX
The Test File- The code- #include -iostream- #include -vector- #includ.docx
PPTX
Java 8 Puzzlers [as presented at OSCON 2016]
PPTX
The groovy puzzlers (as Presented at JavaOne 2014)
PDF
ng-conf 2017: Angular Mischief Maker Slides
Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."
QA Fest 2019. Saar Rachamim. Developing Tools, While Testing
The Ring programming language version 1.6 book - Part 72 of 189
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
Android audio system(audio_hardwareinterace)
Pdr ppt
Transaction is a monad
Functional Thinking for Java Developers (presented in Javafest Bengaluru)
Sequencing Audio Using React and the Web Audio API
Drools5 Community Training Module 3 Drools Expert DRL Syntax
Are we ready to Go?
The Ring programming language version 1.10 book - Part 94 of 212
Network security
ภาษาซี
Groovy puzzlers по русски с Joker 2014
Mary Had a Little λ (QCon)
The Test File- The code- #include -iostream- #include -vector- #includ.docx
Java 8 Puzzlers [as presented at OSCON 2016]
The groovy puzzlers (as Presented at JavaOne 2014)
ng-conf 2017: Angular Mischief Maker Slides
Ad

Recently uploaded (20)

PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Introduction to Artificial Intelligence
PPTX
Essential Infomation Tech presentation.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
System and Network Administraation Chapter 3
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
CHAPTER 2 - PM Management and IT Context
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Softaken Excel to vCard Converter Software.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo Companies in India – Driving Business Transformation.pdf
Nekopoi APK 2025 free lastest update
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
2025 Textile ERP Trends: SAP, Odoo & Oracle
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
How Creative Agencies Leverage Project Management Software.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PTS Company Brochure 2025 (1).pdf.......
Introduction to Artificial Intelligence
Essential Infomation Tech presentation.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
System and Network Administraation Chapter 3
L1 - Introduction to python Backend.pptx
Operating system designcfffgfgggggggvggggggggg
CHAPTER 2 - PM Management and IT Context

JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]

  • 1. JFugue, Music, and the Future of Java David Koelle @dmkoelle Principal Software Engineer, Charles River Analytics Side gig: Author of JFugue
  • 3. Sequencer sequencer = MidiSystem.getSequencer(); Sequence sequence = sequencer.getSequence(); Track track = sequence.createTrack(); ShortMessage onMessage = new ShortMessage(); onMessage.setMessage(ShortMessage.NOTE_ON, 0, 60, 128); MidiEvent noteOnEvent = new MidiEvent(onMessage, 0); track.add(noteOnEvent); ShortMessage offMessage = new ShortMessage(); offMessage.setMessage(ShortMessage.NOTE_OFF, 0, 60, 128); MidiEvent noteOffEvent = new MidiEvent(offMessage, 200); track.add(noteOffEvent); sequencer.start(); try { Thread.sleep(track.ticks()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } “Hello, World!” without JFugue
  • 4. import org.jfugue.player.Player; public class HelloWorld { public static void main(String[] args) { Player player = new Player(); player.play(“C”); } } “Hello, World!” in JFugue
  • 5. public class TwelveBarBlues { public static void main(String[] args) { Pattern pattern = new ChordProgression(“I IV V”) .distribute(“7%6”) .allChordsAs(“$0 $0 $0 $0 $1 $1 $0 $0 $2 $1 $0 $0”) .eachChordAs(“$0i $1i $2i $3i $4i $3i $2i $1i”) .getPattern() .setInstrument(“Acoustic Bass”) .setTempo(120); new Player().play(pattern); } } Advanced JFugue… still fits on one slide
  • 6. A Tour of the Magic of JFugue
  • 7. Easy to Use Based on Music Theory Fun Things are Baked In Consistent “System” Event-Based Architecture Five Bits of JFugue Magic
  • 8. Play music with two lines of code: Player player = new Player(); player.play(“V0 I[Flute] C3MAJw V1 I[Piano] C5q E5q G5h”); Easy to Use
  • 9. Music is easy to specify and intentionally human-readable C Middle-C C#6h C# note, 6th octave, half duration EbMAJ^w E-flat major chord, first inversion, whole duration Easy to Use
  • 10. Music is easy to specify and intentionally human-readable I[Flute] Change instrument to Flute T[Allegro] Change tempo to Allegro (120bpm) m560.8q Play a 560.8 Hz tone at ¼-duration Rq Rest (takes duration just like a note) Easy to Use
  • 11. Define a Scale in terms of Intervals Define a Chord in terms of Intervals Create a “I IV V” Chord Progression Set the Root of a Chord Progression Get the Chords from a Chord Progression Get the Notes from a Chord … Based on Music Theory
  • 12. Rhythm rhythm = new Rhythm() .addLayer("O..oO...O..oOO..") .addLayer("..S...S...S...S.") .addLayer("````````````````") .addLayer("...............+"); new Player() .play(rhythm.getPattern().repeat(2)); Fun Things are Baked In
  • 13. Pattern cp = ChordProgression .fromChords("C#4min E4maj B3maj A3maj") .eachChordAs("$_i $_i Ri $_i") .getPattern() .setInstrument("GUITAR") .setVoice(0); Rhythm rhythm = new Rhythm() .addLayer("..X...X...X...XO"); new Player() .play(new Pattern(cp, rhythm).repeat(2)); Consistent “System”
  • 14. MidiParser parser = new MidiParser(); LilyPondListener listener = new LilyPondListener(); parser.addListener(listener); parser.parse(midi sequence); listener.displayEngravedSheetMusic(); Event-Based Architecture
  • 15. StaccatoParser parser = new StaccatoParser(); LilyPondListener listener = new LilyPondListener(); parser.addListener(listener); parser.parse(“C D E F G A B”); listener.displayEngravedSheetMusic(); Event-Based Architecture
  • 16. StaccatoParser parser = new StaccatoParser(); MusicXmlListener listener = new MusicXmlListener(); parser.addListener(listener); parser.parse(“C D E F G A B”); listener.save(new File(“my_song.xml”)); Event-Based Architecture
  • 17. MidiParser parser = new MidiParser(); MyParserListener listener = new MyParserListener(); parser.addParserListener(listener); parser.parse(MidiSystem.getSequence(new File(“some midi file"))); System.out.println("There are "+listener.counter+" 'C' notes in this music."); class MyParserListener extends ParserListenerAdapter { public int counter; @Override public void onNoteParsed(Note note) { if (note.getPositionInOctave() == 7) { // F# is the 7th note in an octave counter++; } } } Event-Based Architecture
  • 18. Sending to / Receiving from MIDI Devices Creating New Patterns in Real-Time Sending Musical Events “Before” They Occur Extending the Staccato Parser Using Replacement Maps to Play Solfege Writing Functions for Musical Effects (e.g., Trill) Scratching the Surface…
  • 20. Log4JFugue: Listen to your log files! log filesserver video stream is created video stream is destroyed video stream has failed [BASS_DRUM]s [ACOUSTIC_SNARE]s [CRASH_CYMBAL_1]s audio Winner, 2010 Duke’s Choice Award By Brian Tarbox http://www.Log4JFugue.org
  • 21. amount of emotion low emotion counts high emotion counts spikes in emotion active:passive emotions positive:negative emotion amt of emotion per section total emotions in chapter prevalent emotions in novel TransProse: Create Music from Literature stability of note from root note more consonant notes more dissonant notes interesting melodic movement tempo major/minor key and octave note duration main melody additional melodies EmoLex By Hannah Davis http://www.MusicFromText.com
  • 22. Counterpoint Composer What is counterpoint? "The relationship between voices that are interdependent harmonically yet independent in rhythm and contour" By James Weaver http://counterpointservice.cfapps.io
  • 23. JFugue & The Future of Java
  • 24. Streams: Easier to generate procedural music in realtime? Web API: Easier to build collaborative music making experiences? Better garbage collection: No more unexpected pauses in generating music? Kulla / REPL / jshell: Support LiveCoding? Modularity: Good or bad for MIDI support? JFugue & The Future of Java

Editor's Notes

  • #2: My name is David Koelle. I am the author of JFugue, which is a music programming library for Java. I’d like to introduce you to JFugue, show you how it makes music programming fun and easy and magical, give you a few examples of what people are doing with JFugue, and talk about where JFugue is going in the future as Java evolves.
  • #3: I created JFugue because I wanted to bring what you see on the screen into the world. I wanted it to be extremely easy for people to write musical programs. My initial inspiration came in the mid-80’s. I was twelve. I had a Commodore-128 computer. And with that computer, I created music with a command in the BASIC language called “play”. This enthralled me! It helped cement my interest in programming. And made programming fun and joyful. Back then, my only perception about programming was that it was fun and joyful. And then, times changed. Computers and languages got more advanced. And the thing that I once found as a simple pleasure was insanely difficult to do. In the world of modern technology, I couldn’t play music anymore. Now clearly, musical technology advanced. We have amazing digital audio workstations, distribution of MP3s became commonplace, and music recommender systems point us to new music that we might like. But these are either digital instruments for making an audio recording, or involve listening to audio recordings that other people have already created. The ability for an everyday person to easily and simply create a musical program – a program that can make music in response to changing conditions in the world, a program that can be more than a recording of one’s instrument but could be based on that artistic hand to craft generative music – that ability was gone. So this was my quest: to introduce the beauty of what you see on the screen to the world. Well, I achieved that. And once the basics are this simple, it’s possible to build some really cool stuff on top of it. All of these other bits of magic have sprung up to create a joyful and musically sound playground in which to explore and easily create new musical ideas. Really, the essence of JFugue isn’t that you can “play c”, but that you can do a bunch of things that build on this and let you talk about music at a high level. This is the essence JFugue. On the surface, JFugue is a music programming library. it’s a jar file. Its default output is MIDI music. But it contains so much more, some of which you’ll see in the next few minutes. Second, people all around the world are using JFugue to do phenomenally interesting things. I’ll show you a sample of those today. So, this is JFugue’s way of playing Middle-C. But let’s see what this would look like without JFugue.
  • #4: This is the code you would need to play Middle-C without JFugue, using the Java MIDI classes directly. The Java MIDI classes are useful for parsing musical data that’s stored in MIDI files, but they were not developed to be a user-facing music API. Musically, you would want to talk about notes like “C” and durations like “quarter note,” but in this code we’re dealing with notes like 60 and durations like 200 milliseconds. And by the way, this code plays ONE NOTE! Most of the music I enjoy listening to has many more notes than that.
  • #5: This is a simple “Hello, World” program in JFugue
  • #6: And here’s a slightly longer program – still two lines of code, maybe? – that creates twelve bars of blues music, using a I-IV-V chord progression with each chord arpeggiated. “dum-dum-dum-dum, dum-dum-dum-dum” Distribute(“7%6”) turns each of the MAJ chord in the chord progression into a Major 7th chord with a 6th note. (This code plays a total of 96 notes)
  • #10: This human-readable music specification is called Staccato. “Now I know there are other music representations out there!” MusicXML, ABC notation Why create yet another music specification?
  • #11: In MIDI, “Flute” is Instrument 73 Allegro is 120 bpm
  • #12: JFugue doesn’t just play notes, there is a solid foundation of music theory
  • #13: Play “Rock Rhythm”
  • #14: Play “Good Feeling.mid”
  • #15: Staccato-to-MIDI happens to be the default, but you can do stuff like this
  • #18: This code finds all of the F#’s in a piece of music.
  • #20: [PART 2] What these examples really show is the importance of *programming* music (creating music that changes based on conditions in the world, or based on user input) rather than specifying it before hand (as in a DAW)