Composing Music in the Cloud
Counterpoint Composer from a technical perspective
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1882215/counterpoint-composer-icon-360x360.png)
James L. Weaver
Developer / Evangelist
Twitter: @JavaFXpert
Email: jweaver@pivotal.io
http://JavaFXpert.com
http://CulturedEar.com
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/2362760/4080a2492514766cbfaddd717b4b0ab5e761b277_pivotal_logo.png)
@JavaFXpert
Where we'll go today
Composing music algorithmically
- Examine about counterpoint music
- Demo/analyze CounterpointComposer
Composing music via machine learning
- Discuss machine learning
- Demo A.I. Duet
Live demo of CounterpointComposer chord analysis microservice while playing
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3529560/Screen_Shot_2017-02-24_at_2.58.04_PM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3513201/Screen_Shot_2017-02-20_at_6.21.42_PM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1895763/chord-analyzer-architecture.png)
@JavaFXpert
High-level architecture
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1893640/counterpoint-composer-architecture.png)
@JavaFXpert
Source code is in GitHub:
- CounterpointService and Counterpoint Composer UI: https://github.com/JavaFXpert/counterpoint-service
- ChordAnalyzerService and Chord Analyzer Client:
Note: These Technical Presentation slides and Getting Started slides are available on the CounterpointComposer.com Help menu:
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1894130/help-menu.png)
RESTful services & usage
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1893262/rest-services.png)
@JavaFXpert
Exploring other music composition approaches
We'll come back to CounterpointComposer in a bit
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1893640/counterpoint-composer-architecture.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3529290/Thumbtack-e1427312055569.jpg)
@JavaFXpert
Other Music Composition Approaches
Music composition games popularized in 1800s
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3511996/music-composition-dice-yale.jpg)
@JavaFXpert
Music Composition with Machine Learning
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3511733/Screen_Shot_2017-02-20_at_12.41.02_PM.png)
Pivotal Cloud Foundry now runs on Google Cloud Platform
@JavaFXpert
Definition of Machine Learning
"Machine learning is the science of getting computers to learn, without being explicitly programmed"
- Andrew Ng (co-founder of Coursera, Chief Scientist of Baidu)
@JavaFXpert
Anatomy of an Artificial Neural Network
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3067450/artificial-neural-network-labeled.png)
Text
Modeled after the brain
@JavaFXpert
Artificial Neural Network
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3512742/Screen_Shot_2017-02-19_at_8.29.34_AM.png)
@JavaFXpert
Predicting/classifying an elephant
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3512750/Screen_Shot_2017-02-19_at_8.29.43_AM.png)
@JavaFXpert
Predicting/classifying a cat
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3512757/Screen_Shot_2017-02-19_at_8.30.03_AM.png)
@JavaFXpert
Time series prediction with neural networks
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3528941/Screen_Shot_2017-02-24_at_11.43.38_AM.png)
What is happening? What is most likely to happen next?
@JavaFXpert
This is a job for a Recurrent Neural Network
What is happening? What is most likely to happen next?
@JavaFXpert
Music composition with an RNN
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3512763/Screen_Shot_2017-02-19_at_8.32.00_AM.png)
@JavaFXpert
Predicting the most likely next note
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3512799/Screen_Shot_2017-02-19_at_8.32.15_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3528641/note_rnn_model.png)
@JavaFXpert
Playing a duet with neural networks
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3512874/Screen_Shot_2017-02-20_at_6.18.05_PM.png)
@JavaFXpert
Playing a duet with neural networks
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3513201/Screen_Shot_2017-02-20_at_6.21.42_PM.png)
@JavaFXpert
Now back to CounterpointComposer
Let's examine the ChordAnalyzerService
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1893640/counterpoint-composer-architecture.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/3529290/Thumbtack-e1427312055569.jpg)
@JavaFXpert
Let's examine the ChordAnalyzerService
@JavaFXpert
Resource controller
http://example/analyze?notes=G3 D4 B4
Note: Because Jackson 2 is on the classpath, Spring’s MappingJackson2HttpMessageConverter is automatically chosen to convert the MusicChord instance to JSON
@RestController
public class ChordAnalyzerController {
private MusicChord musicChord;
@RequestMapping("/analyze") // endpoints s/b nouns, so analysis is a better name
public MusicChord identifyChordByNotes(@RequestParam(value = "notes") String notes) {
...
return musicChord;
}
}
To learn more, see Building a RESTful Web Service Spring Guide
@JavaFXpert
Resource representation
public class MusicChord {
private final String root;
private final String chordType;
private final String bassNote;
public MusicChord(String root, String chordType, String bassNote) {
this.root = root;
this.chordType = chordType;
this.bassNote = bassNote;
}
public String getRoot() {
return root;
}
public String getChordType() {
return chordType;
}
public String getBassNote() {
return bassNote;
}
}
@JavaFXpert
Make the app executable
package com.culturedear.chord;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ChordAnalyzerServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ChordAnalyzerServiceApplication.class, args);
}
}
To learn more, see Building a RESTful Web Service Spring Guide
@JavaFXpert
App build/deploy cycle
$ mvn clean install
$ cf push
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1893708/cf-push-button.png)
Note: One method of deployment for Spring Boot apps is a JAR file, which contains an embedded Tomcat servlet container.
@JavaFXpert
Pivotal Web Services Console
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1893518/pivotal-web-services-console.png)
@JavaFXpert
start.spring.io
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1893726/start-spring-io.png)
@JavaFXpert
Chord Analyzer Client
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1895763/chord-analyzer-architecture.png)
- http://chordanalyzerservice.cfapps.io/
- Leverages Web MIDI API (currently supported in Chrome)
- Use any MIDI keyboard controller
@JavaFXpert
Counterpoint Composer
from a technical perspective
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/1882215/counterpoint-composer-icon-360x360.png)
James L. Weaver
Developer / Evangelist
Twitter: @JavaFXpert
Email: jweaver@pivotal.io
http://JavaFXpert.com
http://CulturedEar.com
http://CounterpointComposer.com
Hope you enjoyed
![](https://s3.amazonaws.com/media-p.slid.es/uploads/396450/images/2362760/4080a2492514766cbfaddd717b4b0ab5e761b277_pivotal_logo.png)
@JavaFXpert
Counterpoint Composer Technical Perspective
By javafxpert
Counterpoint Composer Technical Perspective
Exploring the technologies employed in Counterpoint Composer
- 32,128