mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2026-04-18 22:55:50 +00:00
准备移植 v2 功能到插件来
This commit is contained in:
@@ -36,12 +36,15 @@ from itertools import chain
|
||||
|
||||
import mido
|
||||
|
||||
from .constants import *
|
||||
from Musicreater.constants import *
|
||||
from .old_exceptions import *
|
||||
from .subclass import *
|
||||
from .old_types import *
|
||||
from .utils import *
|
||||
|
||||
from Musicreater.builtin_plugins.midi_read.constants import *
|
||||
from Musicreater.builtin_plugins.midi_read.utils import *
|
||||
|
||||
"""
|
||||
学习笔记:
|
||||
tempo: microseconds per quarter note 毫秒每四分音符,换句话说就是一拍占多少微秒
|
||||
@@ -796,7 +799,7 @@ class MusicSequence:
|
||||
def add_note(self, channel_no: int, note: MineNote, is_sort: bool = True):
|
||||
"""
|
||||
在指定通道添加一个音符
|
||||
值得注意:在版本 2.2.3 及之前 is_sort 参数默认为 False ;在此之后为 True
|
||||
值得注意:在版本 2.2.3 及之前 is_sort 参数默认为 False;在此之后为 True
|
||||
"""
|
||||
self.channels[channel_no].append(note)
|
||||
self.total_note_count += 1
|
||||
|
||||
@@ -15,7 +15,6 @@ Terms & Conditions: License.md in the root directory
|
||||
# Email TriM-Organization@hotmail.com
|
||||
# 若需转载或借鉴 许可声明请查看仓库目录下的 License.md
|
||||
|
||||
import math
|
||||
import random
|
||||
|
||||
# from io import BytesIO
|
||||
@@ -34,7 +33,7 @@ from typing import (
|
||||
|
||||
from xxhash import xxh3_64, xxh3_128, xxh32
|
||||
|
||||
from .constants import (
|
||||
from Musicreater.constants import (
|
||||
MC_INSTRUMENT_BLOCKS_TABLE,
|
||||
MC_PITCHED_INSTRUMENT_LIST,
|
||||
MM_INSTRUMENT_DEVIATION_TABLE,
|
||||
@@ -127,90 +126,6 @@ def midi_inst_to_mc_sound(
|
||||
)
|
||||
|
||||
|
||||
def velocity_2_distance_natural(
|
||||
vol: float,
|
||||
) -> float:
|
||||
"""
|
||||
midi力度值拟合成的距离函数
|
||||
|
||||
Parameters
|
||||
----------
|
||||
vol: int
|
||||
midi 音符力度值
|
||||
|
||||
Returns
|
||||
-------
|
||||
float播放中心到玩家的距离
|
||||
"""
|
||||
return (
|
||||
-8.081720684086314
|
||||
* math.log(
|
||||
vol + 14.579508825070013,
|
||||
)
|
||||
+ 37.65806375944386
|
||||
if vol < 60.64
|
||||
else 0.2721359356095803 * ((vol + 2592.272889454798) ** 1.358571233418649)
|
||||
+ -6.313841334963396 * (vol + 2592.272889454798)
|
||||
+ 4558.496367823575
|
||||
)
|
||||
|
||||
|
||||
def velocity_2_distance_straight(vol: float) -> float:
|
||||
"""
|
||||
midi力度值拟合成的距离函数
|
||||
|
||||
Parameters
|
||||
----------
|
||||
vol: int
|
||||
midi 音符力度值
|
||||
|
||||
Returns
|
||||
-------
|
||||
float播放中心到玩家的距离
|
||||
"""
|
||||
return vol / -8 + 16
|
||||
|
||||
|
||||
def panning_2_rotation_linear(pan_: float) -> float:
|
||||
"""
|
||||
Midi 左右平衡偏移值线性转为声源旋转角度
|
||||
|
||||
Parameters
|
||||
----------
|
||||
pan_: int
|
||||
Midi 左右平衡偏移值
|
||||
注:此参数为int,范围从 0 到 127,当为 64 时,声源居中
|
||||
|
||||
Returns
|
||||
-------
|
||||
float
|
||||
声源旋转角度
|
||||
"""
|
||||
return (pan_ - 64) * 90 / 63
|
||||
|
||||
|
||||
def panning_2_rotation_trigonometric(pan_: float) -> float:
|
||||
"""
|
||||
Midi 左右平衡偏移值,依照圆的声场定位,转为声源旋转角度
|
||||
|
||||
Parameters
|
||||
----------
|
||||
pan_: int
|
||||
Midi 左右平衡偏移值
|
||||
注:此参数为int,范围从 0 到 127,当为 64 时,声源居中
|
||||
|
||||
Returns
|
||||
-------
|
||||
float
|
||||
声源旋转角度
|
||||
"""
|
||||
if pan_ <= 0:
|
||||
return -90
|
||||
elif pan_ >= 127:
|
||||
return 90
|
||||
else:
|
||||
return math.degrees(math.acos((64 - pan_) / 63)) - 90
|
||||
|
||||
|
||||
def minenote_to_command_parameters(
|
||||
mine_note: MineNote,
|
||||
|
||||
Reference in New Issue
Block a user