Composing Music in the Cloud

Counterpoint Composer from a technical perspective

James L. Weaver
Developer / Evangelist

 

Twitter: @JavaFXpert
Email: jweaver@pivotal.io
http://JavaFXpert.com
http://CulturedEar.com

@JavaFXpert  #DevNexus

High-level architecture

@JavaFXpert  #DevNexus

Source code is in GitHub:

https://github.com/JavaFXpert/chord-analyzer-service

Note: These Technical Presentation slides and Getting Started slides are available on the CounterpointComposer.com Help menu:

RESTful services & usage

@JavaFXpert  #DevNexus

Let's examine the ChordAnalyzerService

@JavaFXpert  #DevNexus

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  #DevNexus

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  #DevNexus

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  #DevNexus

App build/deploy cycle

  1. $ mvn clean install
  2. $ cf push -p ./target/counterpoint-service.jar CounterpointService

Note: One method of deployment for Spring Boot apps is a JAR file, which contains an embedded Tomcat servlet container.

@JavaFXpert  #DevNexus

Pivotal Web Services Console

@JavaFXpert  #DevNexus

start.spring.io

@JavaFXpert  #DevNexus

Other Music Composition Approaches

@JavaFXpert  #DevNexus

Music composition games popularized in 1800s

Music Composition with Machine Learning

@JavaFXpert  #DevNexus

Artificial Neural Network

@JavaFXpert  #DevNexus

Predicting/classifying an elephant

@JavaFXpert  #DevNexus

Predicting/classifying a cat

@JavaFXpert  #DevNexus

Predicting the most likely next note

@JavaFXpert  #DevNexus

Predicting the most likely next note

@JavaFXpert  #DevNexus

Playing a duet with neural networks

@JavaFXpert  #DevNexus

Playing a duet with neural networks

@JavaFXpert  #DevNexus

Chord Analyzer Client

@JavaFXpert  #DevNexus

Counterpoint Composer

from a technical perspective

James L. Weaver
Developer / Evangelist

 

Twitter: @JavaFXpert
Email: jweaver@pivotal.io
http://JavaFXpert.com
http://CulturedEar.com

http://CounterpointComposer.com

Hope you enjoyed

@JavaFXpert  #DevNexus