AI作曲基础-Python编程作曲软件篇-FoxDot文档及源码分析-官方教程01

Posted aiw2s

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AI作曲基础-Python编程作曲软件篇-FoxDot文档及源码分析-官方教程01相关的知识,希望对你有一定的参考价值。

AI作曲基础-Python编程作曲软件篇-FoxDot文档及源码分析-官方教程01

前言

  • 本系列系列目录放在文尾;
  • 本系列是AI作曲的基础,暂时和AI关系不大,但尤为重要;
  • 借助FoxDot,从文档分析开始,然后进入源码分析环节;
  • 暂未发现官方中文版,实践顺带翻译,会根据需要不定期校对及更新,欢迎催更~

正文

教程来源

FoxDot官方主页在此:https://foxdot.org/
FoxDot官方教程在此:https://foxdot.org/tutorials/
注:上面网址内的教程,在FoxDot软件内有~

Tutorial 0: Introduction

# Tutorial 0: Introduction

################
# Executing code

# To execute code in FoxDot, make sure your text cursor is in the 'block' of code
# (sections of text not separated by blank lines) and press Ctrl+Return

# To execute just a single line, even in a block, press Alt+Return

# Try it now, move the cursor to the line of code below and press Ctrl+Return

print("Hello World")

##############
# Help

# If you're ever stuck, or want to know more about a function or class
# just type help followed by the name of that Python object in brackets:

help(object)

Tutorial 1: Playing Notes

# Tutorial 1: Playing Notes

# In FoxDot, all two-character variable names are reserved for player objects, such as 'p1'
# Creating a Player Object with no arguments will play a single note on middle C, by default, repeatedly until stopped.
# Use >> to give one of these to a player object like so:

p1 >> pluck()

# To stop an individual player object, simply execute

p1.stop()

# Besides the 2-character variables that are pre-reserved, you can create your
# own with your own names

foo = Player()
foo >> pluck()

# The >> in Python is usually reserved for a type of operation, like + or -, but it is not the case in FoxDot.
# If a user re-executes the code, FoxDot will update p1 instead of creating a PlayerObject,
# which means you can make changes to your music using just one line of code.

# If you now give your player object some arguments, you can change the notes being played back.
# The first argument should be the degree of the note to be played
# (default is the lowest note of octave 5 of the major scale) and does not need to be specified by name.

# Python, like most programming languages, using zero-indexing when accessing values in an array,
# which means that 0 refers to the first note of the scale.
# Give your player object instructions to make music with their Synth.
# The first argument is the note of the scale to play. The following code
# plays the first three notes of the default scale (major) on repeat.

# For a single note
p1 >> pluck(0)

# Or a list of notes
p1 >> pluck([0,1,2])

# But you’ll need to specify whatever else you want to change...

# Such as note durations, or the length of each note
p1 >> pluck([0,0,0], dur=[1,2,3])

# Or amplitude, the "volume" of each note
p1 >> pluck([0,0,0], amp=[1,2,3])

# If the second list, the amp in this example, is too long, then the first list (the degree) just loops, and are matched with the remaining elements from the second list (the amplitude).
p1 >> pluck([0,2,4], amp=[1,2,3,1,5])

# More generally, all the lists are traversed regardless of their length.
p1 >> pluck([0,2,4], dur=[1,2], amp=[1,2,3,1,5])

# Arguments can be integers, floating points, fractions, lists,
# tuples, or a mix

p1 >> pluck([0,0,0], dur=2)

p1 >> pluck([0,0,0], dur=1.743)

p1 >> pluck([0,0,0], dur=[0.25,0.5,0.75])

p1 >> pluck([0,0,0], dur=[1/4,1/2,3/4])

p1 >> pluck([0,0,0], dur=[1/4,0.25,3])

# Lists of values are iterated over as the Player plays notes
# The following duration equates to:  1,2,3,1,4,3
# If you don't understand this yet, don't worry, more about patterns in the pattern tutorial
p1 >> pluck([0,0,0], dur=[1,[2,4],3])

# Values in tuples are used simultaneously i.e. p1 will play 3 individual notes, then a chord of 3 together at the same time.
p1 >> pluck([0,2,4,(0,2,4)])

# You can also assign values to the attributes of player objects directly
p1.oct = 5

# To see all the names of player attributes, just execute
print(Player.get_attributes())

# More about those later in the player attributes tutorial

# You could store several player instances and assign them at different times
proxy_1 = pads([0,1,2,3], dur=1/2)
proxy_2 = pads([4,5,6,7], dur=1)

p1 >> proxy_1 # Assign the first to p1

p1 >> proxy_2 # This replaces the instructions being followed by p1

# To play multiple sequences at once, just do the same things with another
# Player object:

p1 >> pluck([0, 2, 3, 4], dur=1/2)

p2 >> pads([(0, 2, 4), (3, 5, 7)], dur=8)

# Play only this player, muting others
p1.solo() # default value is 1 (solo on)

# And turn the solo off
p1.solo(0)

# Stop (not just mute) the other players
p1.only()

# Use Ctrl+. to clear everything for the scheduling clock or run
Clock.clear()

系列目录

AI作曲基础-Python编程作曲软件篇-FoxDot文档及源码分析-官方教程01【本文】
以下【建设中】
AI作曲基础-Python编程作曲软件篇-FoxDot文档及源码分析-官方教程02

我得到“您的要求无法解决为一组可安装的软件包。”当我运行作曲家更新

【中文标题】我得到“您的要求无法解决为一组可安装的软件包。”当我运行作曲家更新【英文标题】:I get "Your requirements could not be resolved to an installable set of packages." when I run composer update 【发布时间】:2016-04-08 15:43:27 【问题描述】:

我使用 laravel 5.2 编写了一个应用程序。这个应用程序有模块/包。所有软件包都将位于名为modules 的文件夹中。

我的第一个包位于名为modules/Mikea/Surveys 的文件夹中。 Mikea 是供应商名称,Surveys 是模块/包名称。每个包都有它自己的composer.json 文件,它允许我使用它自己的作曲家配置来配置每个包。 (我目前有一个包裹,但以后可以有更多)

在我的主 composer.json 文件中,我使用 "path" 在存储库部分输入,就像您在以下 composer.json 文件中看到的那样


    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": 
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "laravelcollective/html": "5.2.x-dev",
        "mikea/surveys": "*"
    ,
    "require-dev": 
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "symfony/dom-crawler": "~3.0",
        "symfony/css-selector": " ~3.0"
    ,
    "repositories": [
        
            "type": "path",
            "url": "modules/Mikea/Surveys"
        
    ],
    "autoload": 
        "classmap": [
            "database"
        ],
        "psr-4": 
            "App\\": "app/",
            "Modules\\": "modules/"
        
    ,
    "autoload-dev": 
        "classmap": [
            "tests/TestCase.php"
        ]
    ,
    "scripts": 
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    ,
    "config": 
        "preferred-install": "dist"
    

在第二个 composer.json 文件“包文件”中我有以下内容


    "name": "mikea/surveys",
    "type": "library",
    "description": "Survey System",
    "authors": [
        
            "name": "Mike A",
            "email": "some@email.com"
        
    ],
    "repositories": [
        
            "type": "package",
            "package": 
                "name": "mikea/surveys",
                "version": "0.1.0",
                "source": 
                    "type": "path",
                    "url": "modules/Mikea/Surveys"
                
            
        
    ],
    "require": 
        "php": ">=5.4.0"
    ,
    "autoload": 
        "classmap": [
            "database/migrations",
            "database/seeds"
        ],
        "psr-4": 
            "mikea\\Surveys\\": "src/"
        
    ,
    "minimum-stability": "dev",
    "prefer-stable": true

当我运行composer update 时出现以下错误

F:\xampp\htdocs\proj>composer update
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package mikea/surveys could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

我在这里做错了什么?为什么会出现此错误?

【问题讨论】:

您的文件系统上是否存在modules/Mikea/Surveys? getcomposer.org/doc/05-repositories.md#path @ceejayoz 是的。它位于appdatabases....文件夹旁边 尝试./modules/Mikea/Surveys,并确保modules/Mikea/Surveys/composer.json 是有效的JSON。 @ceejayoz 我应该在哪里使用 ./modules/Mikea/Surveys 我尝试在存储库 url 中使用它,但仍然出现同样的错误? 【参考方案1】:

我相信我想通了。

我必须像这样在我的第二个composer.json 文件中添加一个“版本”标签。至少添加“版本”可以让我没有错误地运行命令


    "name": "mikea/surveys",
    "type": "library",
    "description": "Survey System",
    "version": "0.1.0",
    "authors": [
        
            "name": "Mike A",
            "email": "some@email.com"
        
    ],
    "require": 
        "php": ">=5.4.0"
    ,
    "autoload": 
        "classmap": [
            "database/migrations",
            "database/seeds"
        ],
        "psr-4": 
            "mikea\\Surveys\\": "src/"
        
    ,
    "minimum-stability": "dev",
    "prefer-stable": true

【讨论】:

以上是关于AI作曲基础-Python编程作曲软件篇-FoxDot文档及源码分析-官方教程01的主要内容,如果未能解决你的问题,请参考以下文章

Laravel 作曲家安装给出错误“您的锁定文件不包含兼容的软件包集,请运行作曲家更新”

索尼推出全能音乐AI工具:作曲混音编曲都OK!留给人类发挥的空间不多了

比较好的音乐作曲软件都有哪些?

无法使用作曲家安装软件包

Laravel包的作曲家需要

作曲家更新:您的要求无法解决为一组可安装的软件包