music21:伍佰 《挪威的森林》MIDI 音乐分析

【机器学习】音乐表示Music Representation 因为最基础的MIDI文件只需要起止(Onset、Offset)、绝对音高(MIDI pitch)就可以播放了(音色之类的都可以设为默认如钢琴),因此才会造成数据如此杂乱。MusicXML格式就好得多,因为其是一个面向乐谱显示或排版的格式,包含基本音乐学信息是其基础。 MusicXML文件分为两种类型:score-partwise与score-timewise,其中较为常见的是score-partwise。 基于节拍事件(Beat-based)相比MIDI-like,REMI的异同:事件表示某一特定音高的 阅读详情

pip install music21

以下是使用 music21 对伍佰《挪威的森林》MIDI 音乐进行分析的一些方面:

加载 MIDI 文件

使用 music21 加载《挪威的森林》MIDI 文件,代码如下:

from music21 import converter
score = converter.parse('norwegian_forest.mid')

音符和音高分析

  • 提取音符:通过score.flat.notes可以遍历乐谱中的每个音符,打印出它的音高和音阶。例如:
    notes = score.flat.notes
    for note in notes:
        print(note.nameWithOctave)
    
  • 音高分布:可以统计不同音高的出现频率,了解歌曲中主要使用的音域范围。通过分析这些数据,能发现歌曲是否有频繁使用的特定音高区域,以及音高的跨度情况。一般来说,《挪威的森林》音高跨度适中,主歌部分音高相对平稳,集中在一定范围内,以配合歌词的叙事性;副歌部分音高会有所上升,增强情感的表达。

节奏分析

  • 节拍信息5:通过score.getTimeSignatures()可以获取 MIDI 文件中标记的节拍信息,《挪威的森林》标记的节拍为 4/4、2/4 等。4/4 节拍使得歌曲具有稳定的节奏感,适合表达这种流行风格的情感。
  • 节奏型分析:可以通过观察音符的时长和排列来分析节奏型。例如,主歌部分可能有较多的平稳节奏型,以叙事为主;而副歌部分可能会出现一些切分音或节奏的变化,来增强情感的张力。

和弦分析

使用score.chordify()方法可以将乐谱中的音符转换为和弦,然后通过遍历和弦元素来分析和弦的构成和进行。例如:
 

chords = score.chordify()
for element in chords.recurse().getElementsByClass('Chord'):
    print(element.normalOrder)

通过分析可以发现,《挪威的森林》的和弦进行较为简单和经典,以 Em 和弦为核心,还包括 Bm、Am、D、E、A、G、C 等和弦11。这些和弦的组合和进行为歌曲营造出了独特的氛围,从主歌到副歌的和弦变化,配合着旋律和歌词,推动着歌曲情感的发展。

乐器分析2

《挪威的森林》MIDI 音乐由多种乐器合奏,如弦乐合奏 2、合成主音 6(人声)、电贝斯(指奏)、打击乐器等。可以通过instrument.partitionByInstrument(stream)方法来获取不同乐器的部分,了解每个乐器在歌曲中的作用和演奏内容。例如,弦乐可能在一些部分起到烘托氛围的作用,电吉他在副歌部分增强力量感,贝

music21:伍佰 《泪桥》MIDI 音乐分析 这是一段使用 music21 库对《泪桥》MIDI 音乐进行基础分析的代码,此代码会对 MIDI 文件进行音符、音高、节奏、和弦等方面的分析。 阅读详情

相关推荐

Music21简明指南

music21简明指南 music21是一个由MIT开发的功能强大的计算音乐学分析Python库。相比于pretty_midi库只能处理MIDI文件,music21可以处理包括MusicXML,MIDI,abc等多种格式的音乐文件,并可以从零开始构建音乐文件或对音乐进行分析。 在搜索引擎中搜索music21,大概率会被引导到这个网址:https://web.mit.edu/music21/。我在初...

weixin_38090501的博客 1万+

【AI应用进阶之旅】LangChain大语言模型LLM面试题:LangChain 基础知识

本文梳理了LangChain基础面试题,涵盖核心组件(如ChatModel、PromptTemplate、OutputParser、Runnable等)、模型调用、提示词管理、消息类型及流式/异步调用机制。通过代码示例解析了从模型调用到流程编排的完整开发流程,强调LCEL与Runnable在现代LangChain应用中的核心地位,助力开发者掌握RAG、Agent等进阶技术的基础能力。

程序员林北北的博客 543

python分析乐谱和音乐的包music21

music21 计算机分析音乐的包: Music21 is a Python-based toolkit for computer-aided musicology 完整示例代码 # -*- coding:utf-8 -*- # /usr/bin/python ''' ------------------------------------------------- File Name ...

全网120W+关注AI拉呱,专注人工智能以及科技前沿! 3268

微信小程序获取用户手机号全流程实战(附完整代码)

本文详细介绍了微信小程序获取用户手机号的全流程实战,包括前端授权、后端解密及安全合规要点。通过传统授权按钮和新版手机号快速验证组件两种方案,帮助开发者高效实现功能,并附完整代码示例。重点解析了微信小程序接口的使用技巧和常见问题解决方案,确保数据安全与用户体验。

weixin_29280219的博客 575

SKILL实现电路virtuoso原理图schematic中引脚pin的net自动打上pin label

SKILL实现电路virtuoso原理图schematic中引脚pin的net自动打上pin label

qq_41510657的博客 2631

AstrBot插件开发全攻略:从零编写一个天气查询插件(Python实战)

本文提供了一份详细的AstrBot插件开发实战指南,手把手教你使用Python从零编写一个智能天气查询插件。内容涵盖插件系统核心设计、开发环境搭建、API调用与数据处理、自然语言交互实现以及插件打包发布全流程,帮助你快速掌握基于AstrBot框架的聊天机器人功能扩展技能。

weixin_29212867的博客 1097

用VINS-Fusion跑通EuRoC数据集:Ubuntu22.04+ROS2环境下的保姆级评测指南

本文详细介绍了在Ubuntu22.04和ROS2 Humble环境下使用VINS-Fusion处理EuRoC数据集的完整流程。从环境配置、数据集转换到参数调优和性能评估,提供了一套全面的多传感器融合分析方案,帮助开发者在无人机精准定位场景中实现高效部署与优化。

weixin_29212867的博客 523

用C#完成最小二乘法拟合平面方程,再计算点到面的距离

【代码】用C#完成最小二乘法拟合平面方程,再计算点到面的距离。

MechMaster 651

华为od 面试八股文_数据库_01_含答案

华为od 面试八股文_数据库_01_含答案

MISAYAONE的博客 2178

大聪明教你学Java | Seata 2.5 从下载到运行:全流程编译部署教程

Seata 2.5 版本带来了不少特性优化,但实际部署时却发现一个尴尬问题:全网找不到一篇完整覆盖「Git 源码下载→本地编译→环境配置→启动验证」的实操教程。作为一名踩遍无数坑才成功跑通的开发者,我深知这个过程的煎熬:Git 拉取源码后编译失败、依赖版本冲突、配置文件参数混乱、启动时端口占用或连接报错… 每一个坑都能耗费数小时排查。为了让后续开发者少走弯路,我将自己从0到1的完整实操经验整理成文,跟着步骤走即可成功运行 Seata 2.5.

不肯过江东丶 2084

使用OpenSSL创建多级CA证书链签发证书并导出为pkcs12/p12/pfx文件

文章目录1. 生成根CA证书并自签2. 生成二级CA证书并使用CA证书签发3. 生成服务器证书并使用二级CA证书签发4. 制作CA证书链5. 打包为p12文件6. 注意事项7. 使用`openssl x509`和`openssl ca`签发CA证书的差别 操作步骤: 生成根CA证书并自签 生成二级CA证书并使用CA证书签发 生成服务器证书并使用二级CA证书签发 制作CA证书链 打包为p12文件 1. 生成根CA证书并自签 # 创建root-ca并自签名 openssl req -x509 -newkey

Laurence的技术博客 9579

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: music21:伍佰 《泪桥》MIDI 音乐分析
下一篇: python:mido 提取 midi文件中某一音轨的音乐数据
belldeep
博客等级 码龄20年 1821粉丝 584原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址