CreativePython 0.1.5__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {creativepython-0.1.5/src/CreativePython.egg-info → creativepython-0.1.7}/PKG-INFO +10 -11
- {creativepython-0.1.5 → creativepython-0.1.7}/README.md +7 -9
- {creativepython-0.1.5 → creativepython-0.1.7}/pyproject.toml +3 -2
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/musicalSphere.py +49 -49
- {creativepython-0.1.5 → creativepython-0.1.7/src/CreativePython.egg-info}/PKG-INFO +10 -11
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython.egg-info/requires.txt +2 -1
- {creativepython-0.1.5 → creativepython-0.1.7}/src/_RealtimeAudioPlayer.py +93 -131
- {creativepython-0.1.5 → creativepython-0.1.7}/src/gui.py +402 -246
- {creativepython-0.1.5 → creativepython-0.1.7}/src/midi.py +110 -105
- {creativepython-0.1.5 → creativepython-0.1.7}/src/music.py +30 -3
- {creativepython-0.1.5 → creativepython-0.1.7}/src/osc.py +85 -32
- {creativepython-0.1.5 → creativepython-0.1.7}/LICENSE +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/MANIFEST.in +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/setup.cfg +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/__init__.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/_creativepythonSetup.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/_soundfont.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/.DS_Store +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/ArvoPart.CantusInMemoriam.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/ConcretPH_Xenakis.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/DeepPurple.SmokeOnTheWater.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/JS_Bach.Canon.TriasHarmonica.BWV1072.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/JS_Bach.Canon_1.GoldbergGround.BWV1087.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/Mozart.MusikalischesWurfelspiel.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/PierreCage.StructuresPourDeuxChances.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/RGB_Display.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/TerryRiley.InC.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/arpeggiator1.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/arpeggiator2.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/autumnLeaves.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/axelF.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/biosignals.txt +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/boids.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/brownianMelody.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/changesByTupac.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/clementine.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/continuousPitchInstrumentAudio.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/drumExample.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/drumMachinePattern1.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/drumsComeAlive.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/fibonacci.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/findPitchOctave.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/furElise.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/generativeMusic.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/goldenTree.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/guidoWordMusic.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/harmonicesMundi.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/harmonicesMundiRevisisted.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/harmonographLateral.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/harmonographRotary.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/iPianoBlackDown.png +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/iPianoOctave.png +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/iPianoParallel.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/iPianoSimple.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/iPianoWhiteCenterDown.png +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/iPianoWhiteLeftDown.png +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/iPianoWhiteRightDown.png +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/midiIn1.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/midiIn2.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/midiIn3.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/midiOut.a.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/midiOut.b.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/midiSynthesizer.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/midiSynthesizer2.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/moondog-bird_slament.wav +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/note.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/octoplus.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/oscIn1.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/oscIn2.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/pentatonicMelody.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/pianoPhase.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/pianoRollGenerator.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/playNote.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/proteinMusic.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/randomCircles.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/randomCirclesThroughMidiInput.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/randomCirclesTimed.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/retrograde.a.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/retrograde.b.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/retrograde.c.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/rowYourBoat.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/scaleTutor.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/sierpinskiTriangle.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/simpleButtonInstrument.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/simpleCircleInstrument.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/sineMelody.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/sineMelodyPlus.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/sliderControl.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/sonifyBiosignals.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/sonifyImage.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/soundscapeLoutrakiSunset.jpg +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/stringQuartet.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/textMusic.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/theWayItIs.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/themeAndVariations.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/throwingDice.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/windChimes.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/examples/zipfMetrics.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/resources/.DS_Store +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/resources/550973__luizguilherme_a__clean-guitarr-riff.mp3 +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/resources/chopper.jpg +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython/resources/de-brazzas-monkey.jpg +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython.egg-info/SOURCES.txt +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython.egg-info/dependency_links.txt +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/CreativePython.egg-info/top_level.txt +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/iannix.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/image.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/markov.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/timer.py +0 -0
- {creativepython-0.1.5 → creativepython-0.1.7}/src/zipf.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CreativePython
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: A Python-based software environment for developing algorithmic art projects.
|
|
5
5
|
Author-email: "Dr. Bill Manaris" <manaris@cofc.edu>, Taj Ballinger <ballingertj@g.cofc.edu>, Trevor Ritchie <ritchiets@g.cofc.edu>
|
|
6
6
|
License: MIT License
|
|
@@ -33,11 +33,12 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
33
33
|
Requires-Python: >=3.9
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
License-File: LICENSE
|
|
36
|
+
Requires-Dist: setuptools>=69.0
|
|
36
37
|
Requires-Dist: tinysoundfont>=0.3.6
|
|
37
38
|
Requires-Dist: osc4py3>=1.0.8
|
|
38
39
|
Requires-Dist: mido>=1.3.3
|
|
39
40
|
Requires-Dist: PySide6>=6.9.1
|
|
40
|
-
Requires-Dist: rtmidi>=
|
|
41
|
+
Requires-Dist: python-rtmidi>=1.5.8
|
|
41
42
|
Requires-Dist: sounddevice>=0.5.2
|
|
42
43
|
Requires-Dist: soundfile>=0.13.1
|
|
43
44
|
Requires-Dist: tqdm>=4.67.1
|
|
@@ -64,7 +65,7 @@ This package is still under development.
|
|
|
64
65
|
Before installing CreativePython, you will need:
|
|
65
66
|
|
|
66
67
|
- **Python3**, version 3.9 or greater [[Download](https://www.python.org/downloads/)]
|
|
67
|
-
- **A C++ compiler** (see **Troubleshooting
|
|
68
|
+
- **A C++ compiler** (see **Troubleshooting** below)
|
|
68
69
|
|
|
69
70
|
# Beginner Installation (Windows/MacOS)
|
|
70
71
|
|
|
@@ -78,9 +79,7 @@ Before installing CreativePython, you will need:
|
|
|
78
79
|
|
|
79
80
|
5. If you see `[CreativePython Setup]: CreativePython installed successfully.`, you're all done! You're ready to start using CreativePython in your Python code.
|
|
80
81
|
|
|
81
|
-
- To test the installation,
|
|
82
|
-
|
|
83
|
-
**NOTE**: You can use the setup script in any Python3 environment - not just IDLE!
|
|
82
|
+
- To test the installation, try out the **playNote** example below!
|
|
84
83
|
|
|
85
84
|
# Custom Installation
|
|
86
85
|
|
|
@@ -126,7 +125,7 @@ from music import Note, Play, C4, HN
|
|
|
126
125
|
|
|
127
126
|
Or a similar statement. CreativePython includes a number of useful constants, so we recommend using wildcard imports like `from music import *`.
|
|
128
127
|
|
|
129
|
-
**NOTE
|
|
128
|
+
**NOTE:** The first time you import `music`, CreativePython will download a high-quality soundfont (FluidR3 G2-2.sf2) for you. You should only have to do this once.
|
|
130
129
|
|
|
131
130
|
## Running CreativePython programs
|
|
132
131
|
|
|
@@ -150,14 +149,14 @@ note = Note(C4, HN) # create a middle C half note
|
|
|
150
149
|
Play.midi(note) # and play it!
|
|
151
150
|
```
|
|
152
151
|
|
|
153
|
-
In
|
|
152
|
+
In IDLE, you can open playNote.py, and select **Run**, then **Run Module** from the toolbar.
|
|
153
|
+
|
|
154
|
+
In a terminal, run playNote.py in interactive mode:
|
|
154
155
|
|
|
155
156
|
```
|
|
156
157
|
python -i playNote.py
|
|
157
158
|
```
|
|
158
159
|
|
|
159
|
-
If this is the first time you've used CreativePython, it will ask to download a soundfont.
|
|
160
|
-
|
|
161
160
|
After you do, you should hear a single C4 half-note.
|
|
162
161
|
|
|
163
162
|
## Troubleshooting
|
|
@@ -166,7 +165,7 @@ After you do, you should hear a single C4 half-note.
|
|
|
166
165
|
|
|
167
166
|
Some of CreativePython's libraries need to compile C++ code during installation.
|
|
168
167
|
|
|
169
|
-
- On Windows, download and install [Visual Studio Build Tools 2022](https://visualstudio.microsoft.com/downloads/). In the Visual Studio installer, make sure "C++
|
|
168
|
+
- On Windows, download and install [Visual Studio Build Tools 2022](https://visualstudio.microsoft.com/downloads/). In the Visual Studio installer, make sure "Desktop Development with C++" is checked.
|
|
170
169
|
|
|
171
170
|
- On MacOS, you can download and install [XCode from the App Store](https://apps.apple.com/us/app/xcode/id497799835?mt=12).
|
|
172
171
|
|
|
@@ -14,7 +14,7 @@ This package is still under development.
|
|
|
14
14
|
Before installing CreativePython, you will need:
|
|
15
15
|
|
|
16
16
|
- **Python3**, version 3.9 or greater [[Download](https://www.python.org/downloads/)]
|
|
17
|
-
- **A C++ compiler** (see **Troubleshooting
|
|
17
|
+
- **A C++ compiler** (see **Troubleshooting** below)
|
|
18
18
|
|
|
19
19
|
# Beginner Installation (Windows/MacOS)
|
|
20
20
|
|
|
@@ -28,9 +28,7 @@ Before installing CreativePython, you will need:
|
|
|
28
28
|
|
|
29
29
|
5. If you see `[CreativePython Setup]: CreativePython installed successfully.`, you're all done! You're ready to start using CreativePython in your Python code.
|
|
30
30
|
|
|
31
|
-
- To test the installation,
|
|
32
|
-
|
|
33
|
-
**NOTE**: You can use the setup script in any Python3 environment - not just IDLE!
|
|
31
|
+
- To test the installation, try out the **playNote** example below!
|
|
34
32
|
|
|
35
33
|
# Custom Installation
|
|
36
34
|
|
|
@@ -76,7 +74,7 @@ from music import Note, Play, C4, HN
|
|
|
76
74
|
|
|
77
75
|
Or a similar statement. CreativePython includes a number of useful constants, so we recommend using wildcard imports like `from music import *`.
|
|
78
76
|
|
|
79
|
-
**NOTE
|
|
77
|
+
**NOTE:** The first time you import `music`, CreativePython will download a high-quality soundfont (FluidR3 G2-2.sf2) for you. You should only have to do this once.
|
|
80
78
|
|
|
81
79
|
## Running CreativePython programs
|
|
82
80
|
|
|
@@ -100,14 +98,14 @@ note = Note(C4, HN) # create a middle C half note
|
|
|
100
98
|
Play.midi(note) # and play it!
|
|
101
99
|
```
|
|
102
100
|
|
|
103
|
-
In
|
|
101
|
+
In IDLE, you can open playNote.py, and select **Run**, then **Run Module** from the toolbar.
|
|
102
|
+
|
|
103
|
+
In a terminal, run playNote.py in interactive mode:
|
|
104
104
|
|
|
105
105
|
```
|
|
106
106
|
python -i playNote.py
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
If this is the first time you've used CreativePython, it will ask to download a soundfont.
|
|
110
|
-
|
|
111
109
|
After you do, you should hear a single C4 half-note.
|
|
112
110
|
|
|
113
111
|
## Troubleshooting
|
|
@@ -116,7 +114,7 @@ After you do, you should hear a single C4 half-note.
|
|
|
116
114
|
|
|
117
115
|
Some of CreativePython's libraries need to compile C++ code during installation.
|
|
118
116
|
|
|
119
|
-
- On Windows, download and install [Visual Studio Build Tools 2022](https://visualstudio.microsoft.com/downloads/). In the Visual Studio installer, make sure "C++
|
|
117
|
+
- On Windows, download and install [Visual Studio Build Tools 2022](https://visualstudio.microsoft.com/downloads/). In the Visual Studio installer, make sure "Desktop Development with C++" is checked.
|
|
120
118
|
|
|
121
119
|
- On MacOS, you can download and install [XCode from the App Store](https://apps.apple.com/us/app/xcode/id497799835?mt=12).
|
|
122
120
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "CreativePython"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.7"
|
|
8
8
|
description = "A Python-based software environment for developing algorithmic art projects."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -21,11 +21,12 @@ classifiers = [
|
|
|
21
21
|
"License :: OSI Approved :: MIT License",
|
|
22
22
|
]
|
|
23
23
|
dependencies = [
|
|
24
|
+
"setuptools>=69.0",
|
|
24
25
|
"tinysoundfont>=0.3.6",
|
|
25
26
|
"osc4py3>=1.0.8",
|
|
26
27
|
"mido>=1.3.3",
|
|
27
28
|
"PySide6>=6.9.1",
|
|
28
|
-
"rtmidi>=
|
|
29
|
+
"python-rtmidi>=1.5.8",
|
|
29
30
|
"sounddevice>=0.5.2",
|
|
30
31
|
"soundfile>=0.13.1",
|
|
31
32
|
"tqdm>=4.67.1",
|
|
@@ -15,11 +15,11 @@ from gui import *
|
|
|
15
15
|
from music import *
|
|
16
16
|
from random import *
|
|
17
17
|
from math import *
|
|
18
|
-
from sliderControl import *
|
|
19
|
-
|
|
18
|
+
from sliderControl import *
|
|
19
|
+
|
|
20
20
|
class MusicalSphere:
|
|
21
21
|
"""Creates a revolving sphere that plays music."""
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def __init__(self, radius, density, velocity=0.01, frameRate=30):
|
|
24
24
|
"""
|
|
25
25
|
Construct a revolving sphere with given 'radius', 'density'
|
|
@@ -28,151 +28,151 @@ class MusicalSphere:
|
|
|
28
28
|
second. Each point plays a note when crossing the zero meridian (the
|
|
29
29
|
sphere's meridian (vertical line) closest to the viewer).
|
|
30
30
|
"""
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# musical parameters
|
|
33
33
|
self.instrument = PIANO
|
|
34
34
|
self.scale = MAJOR_SCALE
|
|
35
35
|
self.lowPitch = C1
|
|
36
36
|
self.highPitch = C6
|
|
37
|
-
self.noteDuration = 2000 # milliseconds (2 seconds)
|
|
38
|
-
|
|
37
|
+
self.noteDuration = 2000 # milliseconds (2 seconds)
|
|
38
|
+
|
|
39
39
|
Play.setInstrument(self.instrument, 0) # set the instrument
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
# visual parameters
|
|
42
42
|
self.display = Display("3D Sphere", radius*3, radius*3) # display to draw sphere
|
|
43
43
|
self.display.setColor( Color.BLACK ) # set background color to black
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
self.radius = radius # how wide circle is
|
|
46
46
|
self.numPoints = density # how many points to draw on sphere surface
|
|
47
47
|
self.velocity = velocity # how far it rotates per animation frame
|
|
48
48
|
self.frameRate = frameRate # how many animation frames to do per second
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
self.xCenter = self.display.getWidth() / 2 # to place circle at display's center
|
|
51
51
|
self.yCenter = self.display.getHeight() / 2
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
# sphere data structure (parallel lists)
|
|
54
54
|
self.points = [] # holds the points
|
|
55
55
|
self.thetaValues = [] # holds the points' rotation (azimuthal angle)
|
|
56
56
|
self.phiValues = [] # holds the points' latitude (polar angle)
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
# timer to drive animation
|
|
59
59
|
delay = 1000 / frameRate # convert from frame rate to timer delay (in milliseconds)
|
|
60
60
|
self.timer = Timer(delay, self.movePoints) # timer to schedule movement
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
# control surface for animation frame rate
|
|
63
63
|
xPosition = self.display.getWidth() / 3 # set initial position of display
|
|
64
64
|
yPosition = self.display.getHeight() + 45
|
|
65
65
|
self.control = SliderControl(title="Frame Rate", updateFunction=self.setFrameRate,
|
|
66
66
|
minValue=1, maxValue=120, startValue=self.frameRate,
|
|
67
67
|
x=xPosition, y=yPosition)
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
# orange color gradient (used to display depth, the further away, the darker)
|
|
70
70
|
black = [0, 0, 0] # RGB values for black
|
|
71
71
|
orange = [251, 147, 14] # RGB values for orange
|
|
72
72
|
white = [255, 255, 255] # RGB values for white
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
# create list of gradient colors from black to orange, and from orange to white
|
|
75
75
|
# (a total of 25 colors)
|
|
76
76
|
self.gradientColors = colorGradient(black, orange, 12) + colorGradient(orange, white, 12) + [white] # remember to include the final color
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
self.initSphere() # create the circle
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
self.start() # and start rotating!
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
def start(self):
|
|
83
83
|
"""Starts sphere animation."""
|
|
84
84
|
self.timer.start()
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
def stop(self):
|
|
87
87
|
"""Stops sphere animation."""
|
|
88
88
|
self.timer.stop()
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
def setFrameRate(self, frameRate=30):
|
|
91
91
|
"""Controls speed of sphere animation (by setting how many times per second to move points)."""
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
delay = 1000 / frameRate # convert from frame rate to delay between each update (in milliseconds)
|
|
94
94
|
self.timer.setDelay(delay)
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
def initSphere(self):
|
|
97
97
|
"""Generate a sphere of 'radius' out of points (placed on the surface of the sphere)."""
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
for i in range(self.numPoints): # create all the points
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
# get random spherical coordinates for this point
|
|
102
102
|
r = self.radius # all points are placed *on* the surface
|
|
103
103
|
theta = mapValue( random(), 0.0, 1.0, 0.0, 2*pi) # random rotation (azimuthal angle)
|
|
104
104
|
phi = mapValue( random(), 0.0, 1.0, 0.0, pi) # random latitude (polar angle)
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
# project from spherical to cartesian 3D coordinates (z is depth)
|
|
107
|
-
x, y, z = self.sphericalToCartesian(r, phi, theta)
|
|
108
|
-
|
|
107
|
+
x, y, z = self.sphericalToCartesian(r, phi, theta)
|
|
108
|
+
|
|
109
109
|
# convert depth (z) to color
|
|
110
|
-
color = self.depthToColor(z, self.radius)
|
|
111
|
-
|
|
112
|
-
# create a point
|
|
113
|
-
point = Point(x, y, color
|
|
114
|
-
|
|
110
|
+
color = self.depthToColor(z, self.radius)
|
|
111
|
+
|
|
112
|
+
# create a point at these x, y coordinates
|
|
113
|
+
point = Point(x, y, color)
|
|
114
|
+
|
|
115
115
|
# remember this point and its spherical coordinates (r equals self.radius for all points)
|
|
116
116
|
# (append data for this point to the three parallel lists)
|
|
117
117
|
self.points.append( point )
|
|
118
118
|
self.phiValues.append( phi )
|
|
119
119
|
self.thetaValues.append( theta )
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
# add this point to the display
|
|
122
122
|
self.display.add( point )
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
def sphericalToCartesian(self, r, phi, theta):
|
|
125
|
-
"""Convert spherical to cartesian coordinates."""
|
|
126
|
-
|
|
125
|
+
"""Convert spherical to cartesian coordinates."""
|
|
126
|
+
|
|
127
127
|
# adjust rotation so that theta is 0 at max z (i.e., closest to viewer)
|
|
128
128
|
x = int( r * sin(phi) * cos(theta + pi/2) ) # horizontal axis (pixels are int)
|
|
129
129
|
y = int( r * cos(phi) ) # vertical axis
|
|
130
|
-
z = int( r * sin(phi) * sin(theta + pi/2) ) # depth axis
|
|
131
|
-
|
|
130
|
+
z = int( r * sin(phi) * sin(theta + pi/2) ) # depth axis
|
|
131
|
+
|
|
132
132
|
# move sphere's center to display's center
|
|
133
133
|
x = x + self.xCenter
|
|
134
134
|
y = y + self.yCenter
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
return x, y, z
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
def depthToColor(self, depth, radius):
|
|
139
139
|
"""Map 'depth' to color using the 'gradientColors' RGB colors."""
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
# create color based on position (points further away have less luminosity)
|
|
142
142
|
colorIndex = mapValue(depth, -self.radius, self.radius, 0, len(self.gradientColors)) # map depth to color index
|
|
143
143
|
colorRGB = self.gradientColors[colorIndex] # get corresponding RBG value
|
|
144
144
|
color = Color(colorRGB[0], colorRGB[1], colorRGB[2]) # and create the color
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
return color
|
|
147
|
-
|
|
147
|
+
|
|
148
148
|
def movePoints(self):
|
|
149
149
|
"""Rotate points on y axis as specified by angular velocity."""
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
for i in range(self.numPoints):
|
|
152
152
|
point = self.points[i] # get this point
|
|
153
153
|
theta = (self.thetaValues[i] + self.velocity) % (2*pi) # increment angle to simulate rotation
|
|
154
154
|
phi = self.phiValues[i] # get latitude (altitude)
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
# convert from spherical to cartesian 3D coordinates
|
|
157
157
|
x, y, z = self.sphericalToCartesian(self.radius, phi, theta)
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
if self.thetaValues[i] > theta: # did we just cross the primary meridian?
|
|
160
160
|
color = Color.RED # yes, so sparkle for a split second
|
|
161
161
|
pitch = mapScale(phi, 0, pi, self.lowPitch, self.highPitch, self.scale) # phi is latitude
|
|
162
162
|
dynamic = randint(0, 127) # random dynamic
|
|
163
163
|
Play.note(pitch, 0, self.noteDuration, dynamic) # and play a note (based on latitude)
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
else: # we are not on the primary meridian, so
|
|
166
166
|
# convert depth to color (points further away have less luminosity)
|
|
167
167
|
color = self.depthToColor(z, self.radius)
|
|
168
|
-
|
|
168
|
+
|
|
169
169
|
# adjust this point's position and color
|
|
170
170
|
self.display.move(point, x, y)
|
|
171
171
|
point.setColor(color)
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
# now, remember this point's new theta coordinate
|
|
174
174
|
self.thetaValues[i] = theta
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
#################################################
|
|
177
177
|
# create a sphere
|
|
178
178
|
sphere = MusicalSphere(radius=200, density=200, velocity=0.01, frameRate=30)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CreativePython
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: A Python-based software environment for developing algorithmic art projects.
|
|
5
5
|
Author-email: "Dr. Bill Manaris" <manaris@cofc.edu>, Taj Ballinger <ballingertj@g.cofc.edu>, Trevor Ritchie <ritchiets@g.cofc.edu>
|
|
6
6
|
License: MIT License
|
|
@@ -33,11 +33,12 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
33
33
|
Requires-Python: >=3.9
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
License-File: LICENSE
|
|
36
|
+
Requires-Dist: setuptools>=69.0
|
|
36
37
|
Requires-Dist: tinysoundfont>=0.3.6
|
|
37
38
|
Requires-Dist: osc4py3>=1.0.8
|
|
38
39
|
Requires-Dist: mido>=1.3.3
|
|
39
40
|
Requires-Dist: PySide6>=6.9.1
|
|
40
|
-
Requires-Dist: rtmidi>=
|
|
41
|
+
Requires-Dist: python-rtmidi>=1.5.8
|
|
41
42
|
Requires-Dist: sounddevice>=0.5.2
|
|
42
43
|
Requires-Dist: soundfile>=0.13.1
|
|
43
44
|
Requires-Dist: tqdm>=4.67.1
|
|
@@ -64,7 +65,7 @@ This package is still under development.
|
|
|
64
65
|
Before installing CreativePython, you will need:
|
|
65
66
|
|
|
66
67
|
- **Python3**, version 3.9 or greater [[Download](https://www.python.org/downloads/)]
|
|
67
|
-
- **A C++ compiler** (see **Troubleshooting
|
|
68
|
+
- **A C++ compiler** (see **Troubleshooting** below)
|
|
68
69
|
|
|
69
70
|
# Beginner Installation (Windows/MacOS)
|
|
70
71
|
|
|
@@ -78,9 +79,7 @@ Before installing CreativePython, you will need:
|
|
|
78
79
|
|
|
79
80
|
5. If you see `[CreativePython Setup]: CreativePython installed successfully.`, you're all done! You're ready to start using CreativePython in your Python code.
|
|
80
81
|
|
|
81
|
-
- To test the installation,
|
|
82
|
-
|
|
83
|
-
**NOTE**: You can use the setup script in any Python3 environment - not just IDLE!
|
|
82
|
+
- To test the installation, try out the **playNote** example below!
|
|
84
83
|
|
|
85
84
|
# Custom Installation
|
|
86
85
|
|
|
@@ -126,7 +125,7 @@ from music import Note, Play, C4, HN
|
|
|
126
125
|
|
|
127
126
|
Or a similar statement. CreativePython includes a number of useful constants, so we recommend using wildcard imports like `from music import *`.
|
|
128
127
|
|
|
129
|
-
**NOTE
|
|
128
|
+
**NOTE:** The first time you import `music`, CreativePython will download a high-quality soundfont (FluidR3 G2-2.sf2) for you. You should only have to do this once.
|
|
130
129
|
|
|
131
130
|
## Running CreativePython programs
|
|
132
131
|
|
|
@@ -150,14 +149,14 @@ note = Note(C4, HN) # create a middle C half note
|
|
|
150
149
|
Play.midi(note) # and play it!
|
|
151
150
|
```
|
|
152
151
|
|
|
153
|
-
In
|
|
152
|
+
In IDLE, you can open playNote.py, and select **Run**, then **Run Module** from the toolbar.
|
|
153
|
+
|
|
154
|
+
In a terminal, run playNote.py in interactive mode:
|
|
154
155
|
|
|
155
156
|
```
|
|
156
157
|
python -i playNote.py
|
|
157
158
|
```
|
|
158
159
|
|
|
159
|
-
If this is the first time you've used CreativePython, it will ask to download a soundfont.
|
|
160
|
-
|
|
161
160
|
After you do, you should hear a single C4 half-note.
|
|
162
161
|
|
|
163
162
|
## Troubleshooting
|
|
@@ -166,7 +165,7 @@ After you do, you should hear a single C4 half-note.
|
|
|
166
165
|
|
|
167
166
|
Some of CreativePython's libraries need to compile C++ code during installation.
|
|
168
167
|
|
|
169
|
-
- On Windows, download and install [Visual Studio Build Tools 2022](https://visualstudio.microsoft.com/downloads/). In the Visual Studio installer, make sure "C++
|
|
168
|
+
- On Windows, download and install [Visual Studio Build Tools 2022](https://visualstudio.microsoft.com/downloads/). In the Visual Studio installer, make sure "Desktop Development with C++" is checked.
|
|
170
169
|
|
|
171
170
|
- On MacOS, you can download and install [XCode from the App Store](https://apps.apple.com/us/app/xcode/id497799835?mt=12).
|
|
172
171
|
|