Giter VIP home page Giter VIP logo

music's Introduction

Music

Music is a python package to generate and manipulate music and sounds. It's written using the MASS (Music and Audio in Sample Sequences) framework, a collection of psychophysical descriptions of musical elements in LPCM audio through equations and corresponding Python routines.

To have a further understanding of the routines you can read the article Musical elements in the discrete-time representation of sound.

If you use this package, please cite the forementioned article.

Core features

The precision of Music makes it the perfect choice for many scientific uses. At its core there are a few important features:

  • Sample-based synth, meaning that the state is updated at each sample. For example, when we have a note with a vibrato, each sample is associated to a different frequency. By doing this the synthesized sound is the closest it can be to the mathematical model that describes it.
  • Musical structures with emphasis in symmetry and discourse.
  • Speech and singing interfaces available to synthesize voices.

Music can be used alone or with other packages, and it's ideal for audiovisualization of data. For example, it can be used with Percolation and Participation for harnessing open linked social data, or with audiovisual analytics vocabulary and ontology (AAVO).

How to install

To install music you can either install it directly with pip:

pip3 install music

or you can clone this repository and install it from there:

git clone https://github.com/ttm/music.git
pip3 install -e <path_to_repo>

This install method is especially useful when reloading the modified module in subsequent runs of music, and for greater control of customization, hacking and debugging.

Dependencies

Every dependency is installed by default by pip, but you can take a look at requirements.txt.

To use the singing interface you'll also nead eSpeak, SoX, and abcMIDI, while MIDI.pm and FFT.pm are needed by eCantorix to synthesize singing sequences.

Linux

On Ubuntu everything can be installed with:

sudo apt install espeak sox abcmidi
sudo cpan install MIDI
sudo cpan install Math::FFT

macOS

On macOS you can first install Homebrew, and then:

brew install espeak sox abcmidi perl
cpan install MIDI
cpan install Math::FFT

Examples

Inside the examples folder you can find some scripts that use the main features of Music.

Package structure

The modules are:

  • core:
    • synths for synthesization of notes (including vibratos, glissandos, etc.), noises and envelopes.
    • filters for the application of filters such as ADSR envelopes, fades, IIR and FIR, reverb, loudness, and localization.
    • io for reading and writing WAV files, both mono and stereo.
    • functions for normalization.
  • structures for higher level musical structures such as permutations (and related to algebraic groups and change ringing peals), scales, chords, counterpoint, tunings, etc.
  • singing for singing with eCantorix. While it's not properly documented, and it might need some tweaks, it's working. Speech is currently achieved through espeak in the most obvious way, using os.system as in:
  • legacy for musical pieces that are rendered with the Music package and might be used as material to make more music.
  • tables for the generation of lookup tables for some basic waveform.
  • utils for various functions regarding conversions, mix, etc.

Roadmap

Music is stable but still very young. We didn't have the opportunity yet to make Music all we want it to be.

Here is one example of what we're aiming at:

import music

music.render_demos() # render some wav files in ./

music.legacy.experiments.cristal2(.2, 300) # wav of sonic structure in ./

sound_waves = music.legacy.songs.madame_z(render=False) # return numpy array

sound_waves2 = music.core.io.open("demosong2.wav") # numpy array

music = music.remix(sound_waves, soundwaves2)
music_ = music.horizontal_stack(sound_waves[:44100*2], music[len(music)/2::2])

music.core.io.write_wav_mono(music_)

Coding conventions

The code follows PEP 8 conventions.

For a better understanding of each function, the math behind it and see examples of their use, you can read their docstring.

Further information

Music is primarily intended for artistic use, but was also designed to run psychophysics experiments and data sonification.

You can find an example in Versinus, an animated visualization method for evolving networks that uses Music to render the musical track that represents networks structures.

:::

music's People

Contributors

jacopodonati avatar ttm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

music's Issues

Missing sub-packages after pip install

If you navigate to the folder where the package was installed you'll see that it contains files only, and there are no sub-packages (core, legacy, singing, structures and their sub-packages).

It seems that the problem is on this line of the setup.py. And here you can find how it could be fixed.

Mean Python Error:

Hi,
tested "music" today but cannot get it past the errors:

Traceback (most recent call last):
  File "/Users/gabriel/Desktop/note1.py", line 1, in <module>
    from music import *
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/music/__init__.py", line 1, in <module>
    from .utils import H
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/music/utils.py", line 5, in <module>
    from . import core
ImportError: cannot import name 'core' from partially initialized module 'music' (most likely due to a circular import) (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/music/__init__.py)

Python version is 3.10. error occurs on mac and windows / fresh python install.

from music import *

note = Note(C4, HN)
Play.midi(note)

Or is it the wrong music lib at all?

Regards,
Peter

Circular import when importing the library

import music

gives the following error:

ImportError                               Traceback (most recent call last)
Cell In[5], line 2
      1 ### Basic usage
----> 2 import music as M, numpy as n
      3 T = M.tables.Basic()
      4 H = M.utils.H

File .venv/lib/python3.9/site-packages/music/__init__.py:1
----> 1 from . import utils, tables, synths, effects, structures, singing, core
      2 from . import legacy

ImportError: cannot import name 'structures' from partially initialized module 'music' (most likely due to a circular import)

ImportError

Traceback (most recent call last):
File "test.py", line 6, in
from music import *
File "/usr/local/lib/python3.6/dist-packages/music/init.py", line 2, in
from . import utils, tables, synths, effects, structures, singing
ImportError: cannot import name 'structures'

Cannot import the module

The line import music throws back a long error whose last lines are File "C:\Users\divel\AppData\Local\Programs\Python\Python39\lib\site-packages\numpy\core\function_base.py", line 120, in linspace num = operator.index(num) TypeError: 'float' object cannot be interpreted as an integer
I don't understand where the problem is. Could you please help me? Thank you.

ImportError: No module named 'music.functions'

Hi everyone!

I have a little problem with import music instruction. When I run my program I found this error:

Traceback (most recent call last):
File "MusicTypeGenerator.py", line 3, in
from dataset_generator import DatasetGenerator
File "/home/sophy0295/magenta/magenta/models/music_vae/Tesi_Codice/dataset_generator.py", line 9, in
import music
File "/home/sophy0295/.local/lib/python3.5/site-packages/music/music/init.py", line 1, in
from .utils import H
File "/home/sophy0295/.local/lib/python3.5/site-packages/music/music/utils.py", line 3, in
from .functions import *
ImportError: No module named 'music.functions'

Can you help me? Thank you so much :)

Pip version of Music is broken

I tried to install music in my Python, version 3.10, using pip install --upgrade music. However, it seems the only way I can get Python to import music is if I edit init.py to suppress some imports, otherwise it gives an import error talking about a circular import.
My Operating system is Windows 10, if that helps somehow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.