Coder Social home page Coder Social logo

amsel-core's Introduction

amsel-core

A tool for generative composition producing monophonic phrases, organized into parts and influenced by probability sequences. "Tool" is stressed here because its aim is to be playable in a live context.

Original Doc (Swift)

Configure via .compose files or related messages to give a basic musical frame:

loop, cycles: 8
    A  major, bars: 4
    E  minor, bars: 2
    F  minor, bars: 2
    G# major, bars: 4
end

Instruct the Player object to emit a stream of MIDI events. The Player object holds two probability sequences which can be altered in real time to influence which musical event (note, accent, rest) will be played next.

Example configration:

func playFlutyMelody(output: MIDIOutput?) -> Void {
    
    // Make a sheet
    let aMinPent = Part(root: Note(69), scale: scales["pent-min"]!, length: 16)
    let dMinPent = Part(root: Note(62), scale: scales["pent-min"]!, length: 16)
    let cMajPent = Part(root: Note(60), scale: scales["pent-maj"]!, length: 16)
    let fMajPent = Part(root: Note(53), scale: scales["pent-maj"]!, length: 16)
    let sheetMelo  = Sheet(parts: [aMinPent, dMinPent, cMajPent, fMajPent])
    
    // Give it to the player
    var player = Player(sheet: sheetMelo)
    
    // Instruct the player
    player.behavior.favoredNoteLength       = .Eighth
    player.behavior.noteOrRestProbabiltySeq = [0.5, 0.5]
    
    let allowedRests: [Duration]            = [.Eighth, .Quarter]
    let allowedRestsProbs: [Probability]    = [0.7,     0.3     ]
    
    // Generate the melody
    let melody = player.generateMelodyFromSheet(allowedRest: allowedRests, 
                                                restProbs: allowedRestsProbs)
    
    // Play the melody
    for event in melody.events {
        sendWithRandomVelocity(melodyEvent: event, sendTo: output, tempo: 60)
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.