使用 Swift 图表和画外音图表描述符创作音乐

月亮🎵图表

使用 Swift 图表和画外音图表描述符来创作音乐。🤯

图片来源:https://hadikarimi.com/portfolio/claude-debussy-1908

输出

注意:打开声音以听到输出

歌曲:克莱尔·德·卢恩 克劳德·德彪西

输出.mp4

Method

A basic chart was used with a scale from 0-100 for simplicity.

Setting the value to will play the graph curves, what we want is discrete notes, so we set this value to .AXDataSeriesDescriptorisContinuoustruefalse

Using Piano Key Detector app, the discrete sounds were mapped to music notes across intervals of .5

//        .init(time: 0, value: 0), // C5
//        .init(time: 1, value: 5), // D5
//        .init(time: 2, value: 10), // D5
//        .init(time: 3, value: 15), // D#5
//        .init(time: 4, value: 20), // E5
//        .init(time: 5, value: 25), // E5
//        .init(time: 6, value: 30), // F#5
//        .init(time: 7, value: 35), // F#5
//        .init(time: 8, value: 40), // G#5
//        .init(time: 9, value: 45), // G#5
//        .init(time: 10, value: 50), // A#5
//        .init(time: 12, value: 55), // A#5
//        .init(time: 13, value: 60), // B5
//        .init(time: 14, value: 65), // C6
//        .init(time: 15, value: 70), // C#6
//        .init(time: 16, value: 75), // D6
//        .init(time: 17, value: 80), // D#6
//        .init(time: 18, value: 85), // E6
//        .init(time: 19, value: 90), // F6
//        .init(time: 20, value: 95), // F#6
//        .init(time: 21, value: 100) // G6

Once the notes were identified, a simple version of Clair de Lune was found, https://www.youtube.com/watch?v=ra08MiW8jLw

This was manually mapped to the music notes identified above, with pauses in the song where appropriate.

GitHub

点击跳转