1 people like it.

Undertone: First line of Baa baa black sheep

Playing with Undertone, using operators for terse tune definitions.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
open System.IO
open Undertone
open Undertone.Waves

//C C G G A A AA G 
//Baa baa black sheep have you any wool?
let bpm = 90.
let crotchet = Time.noteValue bpm Time.crotchet
let quaver = Time.noteValue bpm Time.quaver

let (!+) note = 
    Creation.makeNote Creation.sine quaver note 4
let (!!+) note = 
    Creation.makeNote Creation.sine crotchet note 4

let tune = [!+Note.C;!+Note.C;!+Note.G;!+Note.G;!+Note.A;!+Note.A;!!+Note.A;!+Note.G]
           |> Seq.fold Seq.append Seq.empty
           |> Seq.toList

Player.Play tune
namespace System
namespace System.IO
val bpm : float

Full name: Script.bpm
val crotchet : obj

Full name: Script.crotchet
val quaver : obj

Full name: Script.quaver
val note : 'a
val tune : obj list

Full name: Script.tune
module Seq

from Microsoft.FSharp.Collections
val fold : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> 'State

Full name: Microsoft.FSharp.Collections.Seq.fold
val append : source1:seq<'T> -> source2:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.append
val empty<'T> : seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.empty
val toList : source:seq<'T> -> 'T list

Full name: Microsoft.FSharp.Collections.Seq.toList
Raw view New version

More information

Link:http://fssnip.net/eZ
Posted:4 years ago
Author:Michael Newton
Tags: undertone , sequences , progfsharp