Giter Site home page Giter Site logo

pytheory's Introduction

PyTheory: Music Theory for Humans

This (work in progress) library attempts to make exploring music theory approachable to humans.

logo

True Scale -> Pitch Evaluation

>>> from pytheory import TonedScale

>>> c_minor = TonedScale(tonic='C4')['minor']

>>> c_minor
<Scale I=C4 II=D4 III=Eb4 IV=F4 V=G4 VI=Ab4 VII=Bb5 VIII=C5>

>>> c_minor[0].pitch()
523.251130601197

>>> c_minor["I"].pitch(symbolic=True)
440*2**(1/4)

>>> c_minor["tonic"].pitch(temperament='pythagorean', symbolic=True)
14080/27

Audibly play a note (or chord)

>>> from pytheory import play
play(c_minor[0], t=1_000)

Chord Fingerings for Custom Tunings

>>> from pytheory import Tone, Fretboard, CHARTS

>>> tones = (
...     Tone.from_string("F2"),
...     Tone.from_string("C3"),
...     Tone.from_string("G3"),
...     Tone.from_string("D4"),
...     Tone.from_string("A5"),
...     Tone.from_string("E5")
... )

>>> fretboard = Fretboard(tones=tones)
>>>
>>> c_chord = CHARTS['western']["C"]

>>> print(c_chord.fingering(fretboard=fretboard))
(0, 0, 0, 3, 3, 3)

It can also generate charts for all known chords for any instrument (accuracy to be determined!).

โœจ๐Ÿฐโœจ

pytheory's People

Contributors

barseghyanartur avatar dependabot[bot] avatar kennethreitz avatar masonegger avatar monovon avatar ozcanyarimdunya 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  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  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytheory's Issues

C#4 scale

Hi,
I do not understand the following:

In [0]: TonedScale(tonic="C#4")["minor"]
Out[0]:

Why is Scale I=C4 and not I=C#4?

Best wishes

Dict is not callable in TonedScale.scales

>>> toned_scale.scales
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../pytheory/scales.py", line 111, in scales
    return tuple(self._scales().keys())
TypeError: 'dict' object is not callable

pitch != frequency

You appear to call the CPS or Hz frequency pitch. I've always seen pitch defined technically as subjective and scale-related. This seems like it could be called frequency or CPS or Hertz, and sidestep the issue. Personally, pitch is C#3, not a frequency.

Eirikur

NamedTuple Chord

First off - great, fun library.

Your example of the C-chord in some tuning:

>>> print(c_chord.fingering(fretboard=fretboard))
(0, 0, 0, 3, 3, 3)

It was not clear which tuning this was, but modifying your example to standard tuning, the C-chord could be:

>>> print(c_chord.fingering(fretboard=fretboard))
(0, 3, 2, 0, 1, 0)

or is the orientation reversed?

>>> print(c_chord.fingering(fretboard=fretboard))
(0, 1, 0, 2, 3, 0)

You can see the uncertainty in both tuning and orientation. I think returning a namedtuple would clear up these confusions:

>>> print(c_chord.fingering(fretboard=fretboard))
Fingering('E'=0, 'A'=3, 'D'=2, 'G'=0, 'B'=1, 'e'=0)

gist link is broken on README

Heard about this project on talk python -- nice idea! Just wanted to point out that the link to the gist on the README is broken. I would have submitted a PR fixing it but didn't see any public gists under @kenneth-reitz.

Tempraments

I noticed you use "temprament" everywhere, instead of "temperament": is a typo, or is a US pronounce you used? (closed, overlaps PR #1 - commit 2a2e382 into kennethreitz:master)

AttributeError: module 'sympy' has no attribute 'power'

environment
google colab

code

pip install -U pytheory sympy
from pytheory import TonedScale

result

AttributeError                            Traceback (most recent call last)
[<ipython-input-13-78f17bdc43df>](https://localhost:8080/#) in <cell line: 1>()
----> 1 from pytheory import TonedScale

8 frames
[/usr/local/lib/python3.10/dist-packages/pytuning/constants.py](https://localhost:8080/#) in <module>
     31 
     32 edo12_constructors = [
---> 33     (sp.power.Pow(2,sp.Rational(2,12)), "T"),
     34     (sp.power.Pow(2,sp.Rational(1,12)), "s"),
     35 ]

AttributeError: module 'sympy' has no attribute 'power'

image

best regards

Some scales as ionian not working as expected

Sorry if it is not an issue and my lack of musical knoledge instead, but this code did not show what I expected:

`
from pytheory import TonedScale

tsC4 = TonedScale(tonic='C4')
c4_major = tsC4['major']
c4_ionian = tsC4['ionian']
print('major: ' + str(c4_major))
print('ionian: ' + str(c4_ionian))
`

from: https://github.com/txemi/txpymusiclib/blob/master/learn_libs/learn_pytheory/t20_scale_error_report.py

and prints:

major: <Scale I=C4 II=D4 III=E4 IV=F4 V=G4 VI=A5 VII=B5 VIII=C5> ionian: <Scale I=C4 II=C#4 III=D#4 IV=F4 V=F#4 VI=G#4 VII=A#5 VIII=C5>

I expected to find for ionian same notes without decorators as said in:

https://en.wikipedia.org/wiki/Ionian_mode

I found this in muy project trying to merge scales from mingus, musthe and pytherory and watching that pytheory was the one with different output:

https://github.com/txemi/txpymusiclib/blob/master/learn_scales/scales.py

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.