【鼎革‧革鼎】︰ Raspbian Stretch 《六之 J.3‧MIR-3 》

通常熟悉教材思路模式利於掌握學習進入狀況。故此先講

輸入‧處理‧輸出模型︰

IPO model

The input–process–output (IPO) model, or input-process-output pattern, is a widely used approach in systems analysis and software engineering for describing the structure of an information processing program or other process. Many introductory programming and systems analysis texts introduce this as the most basic structure for describing a process.[1][2][3][4]

Overview

A computer program or any other sort of process using the input-process-output model receives inputs from a user or other source, does some computations on the inputs, and returns the results of the computations.[1] In essence the system separates itself from the environment, thus defining both inputs and outputs, as one united mechanism.[5] The system would divide the work into two categories:

  • A requirement from the environment (input)
  • A provision for the environment (output)

In other words, such inputs may be materials, human resources, money or information, transformed into outputs, such as consumables, services, new information or money.

As a consequence, Input-Process-Output system becomes very vulnerable to misinterpretation. This is because, theoretically, it contains all the data, in regards to the environment outside the system, yet on practice, environment contains a significant variety of objects, that a system is unable to comprehend, as it exists outside systems control. As a result it is very important, to understand, where the boundary lies, between the system and the environment, which is beyond systems understanding. This is because, often various analysts, would set their own boundaries, favouring their point of view, thus creating much confusion.[6]

 

指明其與 IPython

讀取‧求值‧輸出循環

Read–eval–print loop

A Read–Eval–Print Loop (REPL), also known as an interactive toplevel or language shell, is a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user; a program written in a REPL environment is executed piecewise. The term is most usually used to refer to programming interfaces similar to the classic Lisp machine interactive environment. Common examples include command line shells and similar environments for programming languages, and is particularly characteristic of scripting languages.[1]

Uses

As a shell, a REPL environment allows users to access relevant features of an operating system in addition to providing access to programming capabilities.

The most common use for REPLs outside of operating system shells is for instantaneous prototyping. Other uses include mathematical calculation, creating documents that integrate scientific analysis (e.g. IPython), interactive software maintenance, benchmarking, and algorithm exploration.

A REPL can become an essential part of learning a new language as it gives quick feedback to the novice.

 

密切相關也。這可說是

Jupyter Audio Basics》文章綱要哩!

舉例而言︰

聲音檔輸入

import librosa
x, sr = librosa.load(‘audio/simple_loop.wav’)

 

視覺化輸出

%matplotlib inline
import seaborn # optional
import matplotlib.pyplot as plt
import librosa.display

plt.figure(figsize=(12, 4))
librosa.display.waveplot(x, sr=sr)

 

stft 處理及顯示

X = librosa.stft(x)
Xdb = librosa.amplitude_to_db(X)
plt.figure(figsize=(12, 5))
librosa.display.specshow(Xdb, sr=sr, x_axis=’time’, y_axis=’hz’)

 

聽覺化輸出

import IPython.display as ipd
ipd.Audio(‘audio/simple_loop.wav’) # load a local WAV file

 

 

 

還請讀者自讀原文,品嚐玩味的吧!

僅補之以

System shell commands

To run any command at the system shell, simply prefix it with !, e.g.:

You can capture the output into a Python list, e.g.: files = !ls. To pass the values of Python variables or expressions to system commands, prefix them with $: !grep -rF $pattern ipython/*. See our shell section for more details.

Define your own system aliases

It’s convenient to have aliases to the system commands you use most often. This allows you to work seamlessly from inside IPython with the same commands you are used to in your system shell. IPython comes with some pre-defined aliases and a complete system for changing directories, both via a stack (see %pushd, %popd and %dhist) and via direct %cd. The latter keeps a history of visited directories and allows you to go to any previously visited one.

 

之說明及用法,了其方便性呦◎

 

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 J.3‧MIR-2 》

雖然有了軟件工具,面對大量 MIR 材料,實難落筆,不知打哪講起哩?心想反正自己亦是新手,何不就隨手寫點學習筆記摘要鏈結吧!或許於人有益也說不定?!

如果讀過簡介

 

多遍以上,將會清楚知道這是以派生 Python 語言為核心,多種程式庫為輔翼,藉著 Jupyter 互動環境,談論音樂資訊檢索的方方面面︰

1. About This Site

About This Site

musicinformationretrieval.com is a collection of instructional materials for music information retrieval (MIR). These materials contain a mix of casual conversation, technical discussion, and Python code.

These pages, including the one you’re reading, are authored using Jupyter notebooks. They are statically hosted using GitHub Pages. The GitHub repository is found here: stevetjoa/stanford-mir.

This material is used during the annual Summer Workshop on Music Information Retrieval at CCRMA, Stanford University. Click here for workshop description and registration.

This site is maintained by Steve Tjoa. For questions, please email steve@stevetjoa.com. Do you have any feedback? Did you find errors or typos? Are you a teacher or researcher and would like to collaborate? Please let me know.

 

2. What is MIR?

While you listen to these excerpts, name as many of its musical characteristics as you can. Can you name the genre? tempo? instruments? mood? time signature? key signature? chord progression? tuning frequency? song structure?

 

What is MIR?

Here is a sampling of tasks found in music information retrieval:

  • fingerprinting
  • cover song detection
  • genre recognition
  • transcription
  • recommendation
  • symbolic melodic similarity
  • mood
  • source separation
  • instrument recognition
  • pitch tracking
  • tempo estimation
  • score alignment
  • song structure/form
  • beat tracking
  • key detection
  • query by humming

 

Why MIR?

  • discover, organize, monetize media collections
  • search (“find me something that sounds like this”) songs, loops, speech, environmental sounds, sound effects
  • workflows in consumer products through machine hearing
  • automatic control of software and mobile devices

 

How is MIR done?

Well, that’s a big question. Two primary areas in music analysis include tonal analysis (e.g. melody and harmony) and rhythm and tempo (e.g. beat tracking). Here are some great overviews by Meinard Müller (author, FMP) on both topics.

 

3. Python Basics

Python Basics

Why Python?

Python is a general-purpose programming language that is popular and easy to use. For new programmers, it is a great choice as a first programming language. In fact, more and more university CS departments are centering their introductory courses around Python.

For a summary of reasons to move from Matlab to Python, please read this post.

This page on Udacity provides some more great reasons to use Python, along with resources for getting started.

 

4. Jupyter Basics

Jupyter Basics

You are looking at a Jupyter Notebook, an interactive Python shell inside of a web browser. With it, you can run individual Python commands and immediately view their output. It’s basically like the Matlab Desktop or Mathematica Notebook but for Python.

To start an interactive Jupyter notebook on your local machine, read the instructions at the GitHub README for this repository.

If you are reading this notebook on http://musicinformationretrieval.com, you are viewing a read-only version of the notebook, not an interactive version. Therefore, the instructions below do not apply.

 

5. Jupyter Audio Basics

Audio Libraries

We will mainly use two libraries for audio acquisition and playback:

1. librosa

librosa is a Python package for music and audio processing by Brian McFee. A large portion was ported from Dan Ellis’s Matlab audio processing examples.

2. IPython.display.Audio

IPython.display.Audio lets you play audio directly in an IPython notebook.

 

6. NumPy and SciPy Basics

NumPy and SciPy

 

The quartet of NumPy, SciPy, Matplotlib, and IPython is a popular combination in the Python world. We will use each of these libraries in this workshop.

 

7. Alphabetical Index of Terms

Alphabetical Index of Terms

Term musicinformationretrieval.com Wikipedia librosa FMP Related
Energy Energy and RMSE Energy (signal processing)   66, 67 Root-mean-square energy
Term musicinformationretrieval.com Wikipedia librosa FMP Related
Root-mean-square energy Energy and RMSE Root mean square librosa.feature.rmse   Energy
Spectrogram STFT and Spectrogram Spectrogram   29, 55 STFT
Short-time Fourier transform

 

故而前行者盡快先能掌握的呦!!??

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 J.3‧MIR-1 》

方將剛起步, 就感覺脖子被掛上個什麼東西?低頭一看,彷彿是張卡片,耳邊響起 W!o 的聲音,說道︰這是『邀請護照』,無照亂走 ,小心一會就被逮了。一時錯愕,怎麼『神遊』也能被逮了! W!o 接著說︰你不要以為這只是個『洞徑』而已,事實上這裡是出入《卡夫卡村 》之『保安關卡』。古來就有多處暗巷密室,由於陽光進不來這裡,傳聞昔日壁上都用油 燈照明。現今可不一樣了,發光可撓性薄膜顯示器、攝像鏡頭、軟 X 光透視、頻譜分析儀、…布滿整個通道,甚至還有『神遊者』感知器的哩。不禁問到︰這真的是可能的嗎?只聽 W!o 自顧自的說︰詳情我也不知。然而凡能『感知者』就可能『被感知』 ;宛如牛頓力學之凡有『作用』通常都會有『反作用』一般。如果從數學的角度看『萬象模 型』,大體總落入『如何計算』罷了。你既是能來,它又豈不能測的呢?雖然講的像這麼回事,終究是匪夷所思的耶!!只不過,假使問已知的『科學原理』是什 麼?當下的『工藝技術』依賴著什麼?果真要用『數理邏輯』觀點來看,若說不是『 □○ 計算』又是什麼呢??……

當面對『奧秘』,單靠『好奇心』是不夠的。問題是該打哪講起的哩 ?不得已遁之以『君子務本』的啊!先行介紹『派生科學』軟件集成的吧!!

SciPy (pronounced “Sigh Pie”) is a Python-based ecosystem of open-source software for mathematics, science, and engineering. In particular, these are some of the core packages:

─ 《勇闖新世界︰ W!o《卡夫卡村》變形祭︰ ○ 局 □ 陣【☵】

 

既邀讀者探索 MIR 筆記︰

Welcome, ISMIR 2017 participants! Contributions are welcome. See GitHub for more info.

焉能不先考慮軟件工具齊備哩?

通讀瀏覽簡介

Introduction

 

後,發現除了選件︰

seaborn: statistical data visualization

 

Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics.For a brief introduction to the ideas behind the package, you can read the introductory notes. More practical information is on the installation page. You may also want to browse the example gallery to get a sense for what you can do with seaborn and then check out the tutorial and API reference to find out how.

To see the code or report a bug, please visit the github repository. General support issues are most at home on stackoverflow, where there is a seaborn tag.

 

之外,實則完整矣!

 

若遇不足者,請自行以

sudo pip3 install □□□

補足也。

須注意該筆記使用的是派生二 Python ,其之print statement 與派生三 Python3 的 print function 不同呦。或可借

print (○○○ )

令二、三者寫法通假勒◎

 

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 J.3‧MIR 》

什麼是音樂資訊檢索 MIR 呢?維基百科詞條這樣說︰

Music information retrieval

Music information retrieval (MIR) is the interdisciplinary science of retrieving information from music. MIR is a small but growing field of research with many real-world applications. Those involved in MIR may have a background in musicology, psychology, academic music study, signal processing, machine learning or some combination of these.

 

它是一種新興跨學科的領域,能有眾多應用︰

Applications

MIR is being used by businesses and academics to categorize, manipulate and even create music.

Recommender systems

Several recommender systems for music already exist, but surprisingly few are based upon MIR techniques, instead making use of similarity between users or laborious data compilation. Pandora, for example, uses experts to tag the music with particular qualities such as “female singer” or “strong bassline”. Many other systems find users whose listening history is similar and suggests unheard music to the users from their respective collections. MIR techniques for similarity in music are now beginning to form part of such systems.

Track separation and instrument recognition

Track separation is about extracting the original tracks as recorded, which could have more than one instrument played per track. Instrument recognition is about identifying the instruments involved and/or separating the music into one track per instrument. Various programs have been developed that can separate music into its component tracks without access to the master copy. In this way e.g. karaoke tracks can be created from normal music tracks, though the process is not yet perfect owing to vocals occupying some of the same frequency space as the other instruments.

Automatic music transcription

Automatic music transcription is the process of converting an audio recording into symbolic notation, such as a score or a MIDI file.[1] This process involves several subtasks, which include multi-pitch detection, onset detection, duration estimation, instrument identification, and the extraction of rhythmic information. This task becomes more difficult with greater numbers of instruments and a greater polyphony level.

Automatic categorization

Musical genre categorization is a common task for MIR and is the usual task for the yearly Music Information Retrieval Evaluation eXchange(MIREX).[2] Machine learning techniques such as Support Vector Machines tend to perform well, despite the somewhat subjective nature of the classification. Other potential classifications include identifying the artist, the place of origin or the mood of the piece. Where the output is expected to be a number rather than a class, regression analysis is required.

Music generation

The automatic generation of music is a goal held by many MIR researchers. Attempts have been made with limited success in terms of human appreciation of the results.

 

昔日高牆深院難窺門徑,今年國際 ISMIR 大會已走過蘇州︰

The 18th International Society for Music Information Retrieval Conference will take place at National University of Singapore Research Institute (NUSRI) in Suzhou, China, October 23-27, 2017. It is organized by National University of Singapore.

Music-Information Retrieval (Music-IR) is a highly interdisciplinary field, incorporating elements from the disciplines of signal processing, machine learning, psychology, musicology, electrical engineering, computer science, and many more. This conference aims to cover the entire area of Music-IR, allowing for researchers, developers, educators, and other professionals to exchange ideas, share results, and gain new perspectives from each other. This in turn will provide sufficient room to foster collaborations and encourage new developments in the field.

For its technical content, ISMIR 2017 will include presentations of research papers, both orally and as posters, and will also feature in-depth tutorials and invited talks on topics of interest to the field. All submitted papers will be subject to rigorous peer-review in order to ensure that those ultimately presented are of the highest-quality and truly speak to the state-of-the-art in the field. Papers will be graded based on novelty, scientific quality, relevance, importance, and readability/organization. Furthermore, ISMIR 2017 will include a section for late-breaking demos (LBDs) to allow for interesting yet nascent ideas to be explored and discussed, as well as an informal brainstorming or discussion ‘unconference’ which will allow for and encourage future collaborations.

Finally, ISMIR 2017 will provide a musical program as well. This program will include a wide diversity of music, from western classical standards to traditional music of the Suzhou area, and will also focus on music incorporating aspects of Music-Information Retrieval. In this way we hope to encourage the use of such techniques in the creation of new music, as well as to explore music which can lead to novel research ideas in the field.

 

新發布一系列極佳教學材料及 IPython Jupyter 筆記︰

Welcome, ISMIR 2017 participants! Contributions are welcome. See GitHub for more info.

Introduction

……

About This Site

musicinformationretrieval.com is a collection of instructional materials for music information retrieval (MIR). These materials contain a mix of casual conversation, technical discussion, and Python code.

These pages, including the one you’re reading, are authored using Jupyter notebooks. They are statically hosted using GitHub Pages. The GitHub repository is found here: stevetjoa/stanford-mir.

This material is used during the annual Summer Workshop on Music Information Retrieval at CCRMA, Stanford University. Click here for workshop description and registration.

This site is maintained by Steve Tjoa. For questions, please email steve@stevetjoa.com. Do you have any feedback? Did you find errors or typos? Are you a teacher or researcher and would like to collaborate? Please let me know.

People who use this site

………

Instructional material for the Music Information Retrieval Workshop at CCRMA, Stanford University, 2014-17. http://musicinformationretrieval.com

stanford-mir

Instructional material for the Music Information Retrieval Workshop at CCRMA, Stanford University, 2014-17.

How to Use This Repo

This repository contains Jupyter notebooks related to music information retrieval (MIR). Inside these notebooks are Python code snippets that illustrate basic MIR systems.

The simplest way to use this repository is to (1) browse a read-only version of this repo at musicinformationretrieval.com, and (2) follow along using a blank Jupyter notebook of your own.

 

特專題介紹,希望有興趣者有個起步也。

 

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 J.3A 》

作者初學乍練實不該多講如何使用 librosa 程式庫之事,此處不過說說測試安裝時閱讀的文件而已。尚祈讀者求教方家也。

於是依著創造者之建議︰

For a quick introduction to using librosa, please refer to the Tutorial. For a more advanced introduction which describes the package design principles, please refer to the librosa paper at SciPy 2015.

 

先修教程

Tutorial

This section covers the fundamentals of developing with librosa, including a package overview, basic and advanced usage, and integration with the scikit-learn package. We will assume basic familiarity with Python and NumPy/SciPy.

Overview

The librosa package is structured as collection of submodules:

  • librosa
    • librosa.beat
      Functions for estimating tempo and detecting beat events.
    • librosa.core
      Core functionality includes functions to load audio from disk, compute various spectrogram representations, and a variety of commonly used tools for music analysis. For convenience, all functionality in this submodule is directly accessible from the top-level librosa.* namespace.
    • librosa.decompose
      Functions for harmonic-percussive source separation (HPSS) and generic spectrogram decomposition using matrix decomposition methods implemented in scikit-learn.
    • librosa.display
      Visualization and display routines using matplotlib.
    • librosa.effects
      Time-domain audio processing, such as pitch shifting and time stretching. This submodule also provides time-domain wrappers for the decompose submodule.
    • librosa.feature
      Feature extraction and manipulation. This includes low-level feature extraction, such as chromagrams, pseudo-constant-Q (log-frequency) transforms, Mel spectrogram, MFCC, and tuning estimation. Also provided are feature manipulation methods, such as delta features, memory embedding, and event-synchronous feature alignment.
    • librosa.filters
      Filter-bank generation (chroma, pseudo-CQT, CQT, etc.). These are primarily internal functions used by other parts of librosa.
    • librosa.onset
      Onset detection and onset strength computation.
    • librosa.output
      Text- and wav-file output.
    • librosa.segment
      Functions useful for structural segmentation, such as recurrence matrix construction, time-lag representation, and sequentially constrained clustering.
    • librosa.util
      Helper utilities (normalization, padding, centering, etc.)

Quickstart

Before diving into the details, we’ll walk through a brief example program

※ 註︰ 此處直接使用 jupyter-notebook ,而非 python3 好剪貼而已。

……

 

然後詳覽系統設計原則

 

接著走馬看花

Librosa example gallery

_images/sphx_glr_plot_segmentation_thumb.png

Laplacian segmentation

 

忽見『聲樂分離』

This notebook demonstrates a simple technique for separating vocals (and other sporadic foreground signals) from accompanying instrumentation.

This is based on the “REPET-SIM” method of Rafii and Pardo, 2012, but includes a couple of modifications and extensions:

  • FFT windows overlap by 1/4, instead of 1/2
  • Non-local filtering is converted into a soft mask by Wiener filtering. This is similar in spirit to the soft-masking method used by Fitzgerald, 2012, but is a bit more numerically stable in practice.

………

 

想起當年卡拉 OK 晶片曾有此功能,只是效果不十分好哩!不知今日卻是如何的呦?

結果光為搞定

audioread 2.1.4

multi-library, cross-platform audio decoding

Latest Version: 2.1.5

Decode audio files using whichever backend is available. The library currently supports:

 

能在 raspbian stretch 裡讀 mp3 檔︰

sudo apt-get install ffmpeg
sudo apt-get install libavcodec-extra-53 libavcodec-extra-56 libavcodec-extra57
sudo apt-get install libav-tools

 

天都已經黑了?!呆望著分離頻譜,哪曉聽來怎麼樣的啊★☆

 

 

 

 

 

 

 

 

 

輕。鬆。學。部落客