CreativePython 0.0.3__tar.gz → 0.1.0__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.
Files changed (26) hide show
  1. {creativepython-0.0.3/src/CreativePython.egg-info → creativepython-0.1.0}/PKG-INFO +63 -28
  2. creativepython-0.1.0/README.md +137 -0
  3. {creativepython-0.0.3 → creativepython-0.1.0}/pyproject.toml +2 -1
  4. {creativepython-0.0.3 → creativepython-0.1.0/src/CreativePython.egg-info}/PKG-INFO +63 -28
  5. {creativepython-0.0.3 → creativepython-0.1.0}/src/CreativePython.egg-info/requires.txt +1 -0
  6. creativepython-0.1.0/src/creativepython_setup.py +85 -0
  7. {creativepython-0.0.3 → creativepython-0.1.0}/src/gui.py +79 -35
  8. {creativepython-0.0.3 → creativepython-0.1.0}/src/midi.py +1 -1
  9. creativepython-0.0.3/README.md +0 -103
  10. creativepython-0.0.3/src/creativepython_setup.py +0 -101
  11. {creativepython-0.0.3 → creativepython-0.1.0}/LICENSE +0 -0
  12. {creativepython-0.0.3 → creativepython-0.1.0}/MANIFEST.in +0 -0
  13. {creativepython-0.0.3 → creativepython-0.1.0}/setup.cfg +0 -0
  14. {creativepython-0.0.3 → creativepython-0.1.0}/src/CreativePython.egg-info/SOURCES.txt +0 -0
  15. {creativepython-0.0.3 → creativepython-0.1.0}/src/CreativePython.egg-info/dependency_links.txt +0 -0
  16. {creativepython-0.0.3 → creativepython-0.1.0}/src/CreativePython.egg-info/entry_points.txt +0 -0
  17. {creativepython-0.0.3 → creativepython-0.1.0}/src/CreativePython.egg-info/top_level.txt +0 -0
  18. {creativepython-0.0.3 → creativepython-0.1.0}/src/_RealtimeAudioPlayer.py +0 -0
  19. {creativepython-0.0.3 → creativepython-0.1.0}/src/__init__.py +0 -0
  20. {creativepython-0.0.3 → creativepython-0.1.0}/src/iannix.py +0 -0
  21. {creativepython-0.0.3 → creativepython-0.1.0}/src/image.py +0 -0
  22. {creativepython-0.0.3 → creativepython-0.1.0}/src/markov.py +0 -0
  23. {creativepython-0.0.3 → creativepython-0.1.0}/src/music.py +0 -0
  24. {creativepython-0.0.3 → creativepython-0.1.0}/src/osc.py +0 -0
  25. {creativepython-0.0.3 → creativepython-0.1.0}/src/timer.py +0 -0
  26. {creativepython-0.0.3 → creativepython-0.1.0}/src/zipf.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CreativePython
3
- Version: 0.0.3
3
+ Version: 0.1.0
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
@@ -41,6 +41,7 @@ Requires-Dist: pyaudio>=0.2.14
41
41
  Requires-Dist: PySide6>=6.9.1
42
42
  Requires-Dist: sounddevice>=0.5.2
43
43
  Requires-Dist: soundfile>=0.13.1
44
+ Requires-Dist: tqdm>=4.67.1
44
45
  Requires-Dist: pooch>=1.8
45
46
  Requires-Dist: platformdirs>=4.2
46
47
  Requires-Dist: pypianoroll>=1.0
@@ -62,12 +63,12 @@ This package is still under development.
62
63
  The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7cwxayca38ajcc533bpgs/AGP4pnP-xhb-5LH_7YPsgyk?rlkey=2led17m6h0ku9y3hzbsnvsio1&dl=1) install CreativePython and all its required software, including Python3, FluidSynth, PortAudio, ffmpeg, Homebrew (on Mac), and Windows Build Kit (on Windows).
63
64
 
64
65
  ### Windows
65
- 1. Open `win-scripts.tgz`. Right-click `windows_setup.bat`, and **Run as Administrator** (it will open PowerShell and run).
66
+ 1. Open `win-scripts.zip`. Right-click `windows_setup.ps1`, and **Run with PowerShell** (it will open a PowerShell window and begin installing).
66
67
  2. Follow any prompts and let it finish.
67
68
  - If you do not have Windows Build Kit installed, it will be installed as part of this process. This may take some time to complete.
68
69
 
69
70
  ### macOS
70
- 1. Open `mac-scripts.tgz`. Control-click `mac_setup.command`, and **Open** (it will open Terminal and run).
71
+ 1. Open `mac-scripts.tgz`. Control-click `mac_setup.command`, and **Open** (it will open a Terminal window and begin installing).
71
72
  2. Follow any prompts and let it finish.
72
73
  - If you do not have Command Line Tools for XCode installed, it will be installed as part of this process. This may take some time to complete.
73
74
 
@@ -80,28 +81,38 @@ The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7
80
81
  ### 1. Install Python 3 + pip
81
82
 
82
83
  #### Windows
83
- 1. Download the [Python 3 installer](https://www.python.org/downloads/).
84
- 2. Run the installer. **Check the box that says “Add Python to PATH”** before clicking *Install Now*.
85
- 3. Open Command Prompt (search for "cmd" in the Start menu).
86
- 4. Verify your installation.
84
+ 1. Open PowerShell as Administrator (search "PowerShell" in the Start menu, and select "Run as Administrator"). Copy and Paste the following commands at each step.
85
+
86
+ 2. Install **Chocolatey** if you don't have it. [(Documentation)](https://docs.chocolatey.org/en-us/choco/setup/) Copy/Paste the following command:
87
+
88
+ ```Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))```
89
+
90
+ When finished, exit this window and open a new PowerShell window.
91
+
92
+ 3. Install Python 3.
93
+
94
+ ```Invoke-Expressed "choco install python -y"```
87
95
 
88
- ```$ python --version```
96
+ 4. Verify that Python was installed.
97
+
98
+ ```py --version```
89
99
 
90
100
  You should see something like "Python 3.12.4"
91
101
 
92
102
  #### MacOS
93
- 1. Open Terminal (press Command + Space, type "Terminal", and hit Enter).
103
+ 1. Open Terminal (press Command + Space, type "Terminal", and hit Enter). Copy and Paste the following commands at each step.
104
+
94
105
  2. Install **Homebrew** if you don't have it.
95
106
 
96
- ```$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"```
107
+ ```/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"```
97
108
 
98
109
  3. Install Python 3.
99
110
 
100
- ```$ brew install python```
111
+ ```brew install python```
101
112
 
102
113
  4. Verify your installation.
103
114
 
104
- ```$ python3 --version```
115
+ ```python3 --version```
105
116
 
106
117
  You should see something like "Python 3.12.4"
107
118
 
@@ -110,27 +121,53 @@ The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7
110
121
  ### 2. Install System Libraries
111
122
 
112
123
  #### Windows
124
+ - **Microsoft Build Tools**
125
+ Microsoft Build Tools contains the necessary tools to compile C++ packages that come with some Python libraries.
126
+
127
+ 1. Open a new PowerShell window.
128
+
129
+ 2. Download the latest Microsoft Build Tools.
130
+
131
+ ```Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe"```
132
+
133
+ 3. Run the Installer.
134
+
135
+ ```Start-Process "$env:TEMP\vs_buildtools.exe" -ArgumentList "--installPath C:\Program Files\Microsoft Build Tools" --quiet --wait --norestart --nocache --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools" -Wait```
136
+
137
+ 4. Add Build Tools to your PATH.
138
+
139
+ ```[Environment]::SetEnvironmentVariable("PATH", "$(Join-Path (Get-ChildItem 'C:\Program Files\Microsoft Build Tools\VC\Tools\MSVC' -Directory | Sort-Object Name -Descending | Select-Object -First 1).FullName 'bin\Hostx64\x64');$env:PATH", [EnvironmentVariableTarget]::Machine)```
140
+
141
+ 5. Verify your Installation.
142
+
143
+ ```Get-Command nmake.exe```
144
+
145
+ You should see a list of Applications, likely only containing 'nmake.exe'.
146
+
147
+ If you get an error, try the command in a new PowerShell window.
148
+
149
+
113
150
  - **PortAudio**:
114
- On Windows, PortAudio is installed automatically with CreativePython, however you need Microsoft Build Tools installed first.
115
- 1. Download [the latest Windows build](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
116
- 2. Run the installer. When prompted, select **C++ build tools**.
117
- 3. Click **Install**. This may take several minutes.
151
+ On Windows, PortAudio comes with our Python libraries below.
118
152
 
119
153
  - **FluidSynth**:
120
- 1. Download [the latest Windows build](https://github.com/FluidSynth/fluidsynth/releases).
121
- 2. Unzip it, and add the folder's location to your PATH.
154
+ 1. Open a new PowerShell window.
155
+ 2. Install the latest FluidSynth.
156
+
157
+ ```Invoke-Expression "choco install fluidsynth -y"```
122
158
 
123
159
  - **ffmpeg**:
124
- 1. Download [the latest Windows build](ffmpeg.org/download.html).
125
- 2. Unzip it, and move the folder to `C:\ffmpeg`.
126
- 3. Add `C:\ffmpeg\bin` to your PATH.
160
+ 1. Open a new PowerShell window.
161
+ 2. Install the latest FFmpeg.
162
+
163
+ ```Invoke-Expression "choco install ffmpeg -y"```
127
164
 
128
165
  #### Mac
129
166
  - **All Libraries**:
130
167
  1. Open Terminal.
131
168
  2. Install PortAudio, FluidSynth, and ffmpeg.
132
169
 
133
- ```$ brew install portaudio fluidsynth ffmpeg```
170
+ ```brew install portaudio fluidsynth ffmpeg```
134
171
 
135
172
  ---
136
173
 
@@ -139,16 +176,14 @@ The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7
139
176
  #### Any OS
140
177
  1. Open Command Prompt/Terminal.
141
178
 
142
- ```$ pip install CreativePython```
143
-
144
- ```$ cp-setup```
179
+ ```pip install CreativePython```
145
180
 
146
- 2. When prompted, download the default soundfont. (It's FluidR3 GM2-2, by the way)
181
+ ```cp-setup```
147
182
 
148
- - If you choose not to download the soundfont, you will need to provide your own.
183
+ 2. When prompted, download the default soundfont (It's FluidR3 GM2-2, by the way). If you choose not to download the soundfont, you will need to provide your own.
149
184
 
150
185
  3. Verify your installation.
151
186
 
152
- ```$ cp-test```
187
+ ```cp-test```
153
188
 
154
189
  You should hear a single MIDI note played at C4. If so, you're all set!
@@ -0,0 +1,137 @@
1
+ # CreativePython
2
+
3
+ CreativePython is a Python-based software environment for developing algorithmic art projects. It mirrors the [JythonMusic API](https://jythonmusic.me/api-reference/).
4
+
5
+ This package is still under development.
6
+
7
+ ---
8
+
9
+ ## Quick Install
10
+
11
+ The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7cwxayca38ajcc533bpgs/AGP4pnP-xhb-5LH_7YPsgyk?rlkey=2led17m6h0ku9y3hzbsnvsio1&dl=1) install CreativePython and all its required software, including Python3, FluidSynth, PortAudio, ffmpeg, Homebrew (on Mac), and Windows Build Kit (on Windows).
12
+
13
+ ### Windows
14
+ 1. Open `win-scripts.zip`. Right-click `windows_setup.ps1`, and **Run with PowerShell** (it will open a PowerShell window and begin installing).
15
+ 2. Follow any prompts and let it finish.
16
+ - If you do not have Windows Build Kit installed, it will be installed as part of this process. This may take some time to complete.
17
+
18
+ ### macOS
19
+ 1. Open `mac-scripts.tgz`. Control-click `mac_setup.command`, and **Open** (it will open a Terminal window and begin installing).
20
+ 2. Follow any prompts and let it finish.
21
+ - If you do not have Command Line Tools for XCode installed, it will be installed as part of this process. This may take some time to complete.
22
+
23
+ ---
24
+
25
+ ## Custom Install
26
+
27
+ ---
28
+
29
+ ### 1. Install Python 3 + pip
30
+
31
+ #### Windows
32
+ 1. Open PowerShell as Administrator (search "PowerShell" in the Start menu, and select "Run as Administrator"). Copy and Paste the following commands at each step.
33
+
34
+ 2. Install **Chocolatey** if you don't have it. [(Documentation)](https://docs.chocolatey.org/en-us/choco/setup/) Copy/Paste the following command:
35
+
36
+ ```Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))```
37
+
38
+ When finished, exit this window and open a new PowerShell window.
39
+
40
+ 3. Install Python 3.
41
+
42
+ ```Invoke-Expressed "choco install python -y"```
43
+
44
+ 4. Verify that Python was installed.
45
+
46
+ ```py --version```
47
+
48
+ You should see something like "Python 3.12.4"
49
+
50
+ #### MacOS
51
+ 1. Open Terminal (press Command + Space, type "Terminal", and hit Enter). Copy and Paste the following commands at each step.
52
+
53
+ 2. Install **Homebrew** if you don't have it.
54
+
55
+ ```/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"```
56
+
57
+ 3. Install Python 3.
58
+
59
+ ```brew install python```
60
+
61
+ 4. Verify your installation.
62
+
63
+ ```python3 --version```
64
+
65
+ You should see something like "Python 3.12.4"
66
+
67
+ ---
68
+
69
+ ### 2. Install System Libraries
70
+
71
+ #### Windows
72
+ - **Microsoft Build Tools**
73
+ Microsoft Build Tools contains the necessary tools to compile C++ packages that come with some Python libraries.
74
+
75
+ 1. Open a new PowerShell window.
76
+
77
+ 2. Download the latest Microsoft Build Tools.
78
+
79
+ ```Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe"```
80
+
81
+ 3. Run the Installer.
82
+
83
+ ```Start-Process "$env:TEMP\vs_buildtools.exe" -ArgumentList "--installPath C:\Program Files\Microsoft Build Tools" --quiet --wait --norestart --nocache --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools" -Wait```
84
+
85
+ 4. Add Build Tools to your PATH.
86
+
87
+ ```[Environment]::SetEnvironmentVariable("PATH", "$(Join-Path (Get-ChildItem 'C:\Program Files\Microsoft Build Tools\VC\Tools\MSVC' -Directory | Sort-Object Name -Descending | Select-Object -First 1).FullName 'bin\Hostx64\x64');$env:PATH", [EnvironmentVariableTarget]::Machine)```
88
+
89
+ 5. Verify your Installation.
90
+
91
+ ```Get-Command nmake.exe```
92
+
93
+ You should see a list of Applications, likely only containing 'nmake.exe'.
94
+
95
+ If you get an error, try the command in a new PowerShell window.
96
+
97
+
98
+ - **PortAudio**:
99
+ On Windows, PortAudio comes with our Python libraries below.
100
+
101
+ - **FluidSynth**:
102
+ 1. Open a new PowerShell window.
103
+ 2. Install the latest FluidSynth.
104
+
105
+ ```Invoke-Expression "choco install fluidsynth -y"```
106
+
107
+ - **ffmpeg**:
108
+ 1. Open a new PowerShell window.
109
+ 2. Install the latest FFmpeg.
110
+
111
+ ```Invoke-Expression "choco install ffmpeg -y"```
112
+
113
+ #### Mac
114
+ - **All Libraries**:
115
+ 1. Open Terminal.
116
+ 2. Install PortAudio, FluidSynth, and ffmpeg.
117
+
118
+ ```brew install portaudio fluidsynth ffmpeg```
119
+
120
+ ---
121
+
122
+ ### 3. Install CreativePython
123
+
124
+ #### Any OS
125
+ 1. Open Command Prompt/Terminal.
126
+
127
+ ```pip install CreativePython```
128
+
129
+ ```cp-setup```
130
+
131
+ 2. When prompted, download the default soundfont (It's FluidR3 GM2-2, by the way). If you choose not to download the soundfont, you will need to provide your own.
132
+
133
+ 3. Verify your installation.
134
+
135
+ ```cp-test```
136
+
137
+ You should hear a single MIDI note played at C4. If so, you're all set!
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "CreativePython"
7
- version = "0.0.3"
7
+ version = "0.1.0"
8
8
  description = "A Python-based software environment for developing algorithmic art projects."
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -29,6 +29,7 @@ dependencies = [
29
29
  "PySide6>=6.9.1",
30
30
  "sounddevice>=0.5.2",
31
31
  "soundfile>=0.13.1",
32
+ "tqdm>=4.67.1",
32
33
  "pooch>=1.8",
33
34
  "platformdirs>=4.2",
34
35
  "pypianoroll>=1.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CreativePython
3
- Version: 0.0.3
3
+ Version: 0.1.0
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
@@ -41,6 +41,7 @@ Requires-Dist: pyaudio>=0.2.14
41
41
  Requires-Dist: PySide6>=6.9.1
42
42
  Requires-Dist: sounddevice>=0.5.2
43
43
  Requires-Dist: soundfile>=0.13.1
44
+ Requires-Dist: tqdm>=4.67.1
44
45
  Requires-Dist: pooch>=1.8
45
46
  Requires-Dist: platformdirs>=4.2
46
47
  Requires-Dist: pypianoroll>=1.0
@@ -62,12 +63,12 @@ This package is still under development.
62
63
  The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7cwxayca38ajcc533bpgs/AGP4pnP-xhb-5LH_7YPsgyk?rlkey=2led17m6h0ku9y3hzbsnvsio1&dl=1) install CreativePython and all its required software, including Python3, FluidSynth, PortAudio, ffmpeg, Homebrew (on Mac), and Windows Build Kit (on Windows).
63
64
 
64
65
  ### Windows
65
- 1. Open `win-scripts.tgz`. Right-click `windows_setup.bat`, and **Run as Administrator** (it will open PowerShell and run).
66
+ 1. Open `win-scripts.zip`. Right-click `windows_setup.ps1`, and **Run with PowerShell** (it will open a PowerShell window and begin installing).
66
67
  2. Follow any prompts and let it finish.
67
68
  - If you do not have Windows Build Kit installed, it will be installed as part of this process. This may take some time to complete.
68
69
 
69
70
  ### macOS
70
- 1. Open `mac-scripts.tgz`. Control-click `mac_setup.command`, and **Open** (it will open Terminal and run).
71
+ 1. Open `mac-scripts.tgz`. Control-click `mac_setup.command`, and **Open** (it will open a Terminal window and begin installing).
71
72
  2. Follow any prompts and let it finish.
72
73
  - If you do not have Command Line Tools for XCode installed, it will be installed as part of this process. This may take some time to complete.
73
74
 
@@ -80,28 +81,38 @@ The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7
80
81
  ### 1. Install Python 3 + pip
81
82
 
82
83
  #### Windows
83
- 1. Download the [Python 3 installer](https://www.python.org/downloads/).
84
- 2. Run the installer. **Check the box that says “Add Python to PATH”** before clicking *Install Now*.
85
- 3. Open Command Prompt (search for "cmd" in the Start menu).
86
- 4. Verify your installation.
84
+ 1. Open PowerShell as Administrator (search "PowerShell" in the Start menu, and select "Run as Administrator"). Copy and Paste the following commands at each step.
85
+
86
+ 2. Install **Chocolatey** if you don't have it. [(Documentation)](https://docs.chocolatey.org/en-us/choco/setup/) Copy/Paste the following command:
87
+
88
+ ```Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))```
89
+
90
+ When finished, exit this window and open a new PowerShell window.
91
+
92
+ 3. Install Python 3.
93
+
94
+ ```Invoke-Expressed "choco install python -y"```
87
95
 
88
- ```$ python --version```
96
+ 4. Verify that Python was installed.
97
+
98
+ ```py --version```
89
99
 
90
100
  You should see something like "Python 3.12.4"
91
101
 
92
102
  #### MacOS
93
- 1. Open Terminal (press Command + Space, type "Terminal", and hit Enter).
103
+ 1. Open Terminal (press Command + Space, type "Terminal", and hit Enter). Copy and Paste the following commands at each step.
104
+
94
105
  2. Install **Homebrew** if you don't have it.
95
106
 
96
- ```$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"```
107
+ ```/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"```
97
108
 
98
109
  3. Install Python 3.
99
110
 
100
- ```$ brew install python```
111
+ ```brew install python```
101
112
 
102
113
  4. Verify your installation.
103
114
 
104
- ```$ python3 --version```
115
+ ```python3 --version```
105
116
 
106
117
  You should see something like "Python 3.12.4"
107
118
 
@@ -110,27 +121,53 @@ The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7
110
121
  ### 2. Install System Libraries
111
122
 
112
123
  #### Windows
124
+ - **Microsoft Build Tools**
125
+ Microsoft Build Tools contains the necessary tools to compile C++ packages that come with some Python libraries.
126
+
127
+ 1. Open a new PowerShell window.
128
+
129
+ 2. Download the latest Microsoft Build Tools.
130
+
131
+ ```Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe"```
132
+
133
+ 3. Run the Installer.
134
+
135
+ ```Start-Process "$env:TEMP\vs_buildtools.exe" -ArgumentList "--installPath C:\Program Files\Microsoft Build Tools" --quiet --wait --norestart --nocache --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools" -Wait```
136
+
137
+ 4. Add Build Tools to your PATH.
138
+
139
+ ```[Environment]::SetEnvironmentVariable("PATH", "$(Join-Path (Get-ChildItem 'C:\Program Files\Microsoft Build Tools\VC\Tools\MSVC' -Directory | Sort-Object Name -Descending | Select-Object -First 1).FullName 'bin\Hostx64\x64');$env:PATH", [EnvironmentVariableTarget]::Machine)```
140
+
141
+ 5. Verify your Installation.
142
+
143
+ ```Get-Command nmake.exe```
144
+
145
+ You should see a list of Applications, likely only containing 'nmake.exe'.
146
+
147
+ If you get an error, try the command in a new PowerShell window.
148
+
149
+
113
150
  - **PortAudio**:
114
- On Windows, PortAudio is installed automatically with CreativePython, however you need Microsoft Build Tools installed first.
115
- 1. Download [the latest Windows build](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
116
- 2. Run the installer. When prompted, select **C++ build tools**.
117
- 3. Click **Install**. This may take several minutes.
151
+ On Windows, PortAudio comes with our Python libraries below.
118
152
 
119
153
  - **FluidSynth**:
120
- 1. Download [the latest Windows build](https://github.com/FluidSynth/fluidsynth/releases).
121
- 2. Unzip it, and add the folder's location to your PATH.
154
+ 1. Open a new PowerShell window.
155
+ 2. Install the latest FluidSynth.
156
+
157
+ ```Invoke-Expression "choco install fluidsynth -y"```
122
158
 
123
159
  - **ffmpeg**:
124
- 1. Download [the latest Windows build](ffmpeg.org/download.html).
125
- 2. Unzip it, and move the folder to `C:\ffmpeg`.
126
- 3. Add `C:\ffmpeg\bin` to your PATH.
160
+ 1. Open a new PowerShell window.
161
+ 2. Install the latest FFmpeg.
162
+
163
+ ```Invoke-Expression "choco install ffmpeg -y"```
127
164
 
128
165
  #### Mac
129
166
  - **All Libraries**:
130
167
  1. Open Terminal.
131
168
  2. Install PortAudio, FluidSynth, and ffmpeg.
132
169
 
133
- ```$ brew install portaudio fluidsynth ffmpeg```
170
+ ```brew install portaudio fluidsynth ffmpeg```
134
171
 
135
172
  ---
136
173
 
@@ -139,16 +176,14 @@ The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7
139
176
  #### Any OS
140
177
  1. Open Command Prompt/Terminal.
141
178
 
142
- ```$ pip install CreativePython```
143
-
144
- ```$ cp-setup```
179
+ ```pip install CreativePython```
145
180
 
146
- 2. When prompted, download the default soundfont. (It's FluidR3 GM2-2, by the way)
181
+ ```cp-setup```
147
182
 
148
- - If you choose not to download the soundfont, you will need to provide your own.
183
+ 2. When prompted, download the default soundfont (It's FluidR3 GM2-2, by the way). If you choose not to download the soundfont, you will need to provide your own.
149
184
 
150
185
  3. Verify your installation.
151
186
 
152
- ```$ cp-test```
187
+ ```cp-test```
153
188
 
154
189
  You should hear a single MIDI note played at C4. If so, you're all set!
@@ -6,6 +6,7 @@ pyaudio>=0.2.14
6
6
  PySide6>=6.9.1
7
7
  sounddevice>=0.5.2
8
8
  soundfile>=0.13.1
9
+ tqdm>=4.67.1
9
10
  pooch>=1.8
10
11
  platformdirs>=4.2
11
12
  pypianoroll>=1.0
@@ -0,0 +1,85 @@
1
+ ### SOUNDFONT DOWNLOAD HELPERS
2
+
3
+ from pathlib import Path # using Path to disambiguate between Windows and Unix path schemes
4
+ from platformdirs import user_data_dir
5
+ from pooch import retrieve # secure file download
6
+ import os
7
+
8
+ APP = "CreativePython"
9
+ ORG = "CofC"
10
+
11
+ SOUNDFONT_NAME = "default.sf2"
12
+ CACHE_DIR = Path(user_data_dir(APP, ORG)) / "SoundFonts"
13
+ SOUNDFONT_PATH = CACHE_DIR / SOUNDFONT_NAME
14
+
15
+ SF2_URL = "https://www.dropbox.com/s/xixtvox70lna6m2/FluidR3%20GM2-2.SF2?dl=1"
16
+ SF2_SHA256 = "2ae766ab5c5deb6f7fffacd6316ec9f3699998cce821df3163e7b10a78a64066"
17
+
18
+ def find_soundfont(path=None):
19
+ """
20
+ Finds a soundfont 'default.sf2' in the cache, and returns its location.
21
+ explicit can be another path that may have the soundfont needed.
22
+ """
23
+ candidates = [] # possible soundfont paths
24
+ soundfont = None # actual soundfont path
25
+
26
+ # was a path sent as an argument?
27
+ if path:
28
+ candidates.append(Path(path))
29
+
30
+ # is there a PATH variable?
31
+ env = os.getenv("CREATIVEPYTHON_SOUNDFONT")
32
+ if env:
33
+ candidates.append(Path(env))
34
+
35
+ # CreativePython default sondfont directory
36
+ candidates += [SOUNDFONT_PATH, Path.home() / "SoundFonts" / SOUNDFONT_NAME]
37
+
38
+ # set the first confirmed soundfont
39
+ for c in candidates:
40
+ if c and c.exists() and soundfont is None:
41
+ soundfont = str(c)
42
+
43
+ return soundfont
44
+
45
+
46
+ def download_soundfont(destination):
47
+ """Downloads a default soundfont (FluidR3 GM2-2) and saves it to the user's cache."""
48
+ destination.parent.mkdir(parents=True, exist_ok=True) # create destination directory
49
+ path = retrieve( # download soundfont
50
+ url=SF2_URL,
51
+ known_hash=f"sha256:{SF2_SHA256}",
52
+ progressbar=True,
53
+ fname=destination.name,
54
+ path=str(destination.parent)
55
+ )
56
+ return Path(path) # return the downloaded file's path
57
+
58
+
59
+ ### MAIN METHODS
60
+
61
+ def run():
62
+ # Check for soundfont file
63
+ sf = find_soundfont()
64
+
65
+ # Attempt to download missing soundfont, if needed
66
+ if not sf:
67
+ print("CreativePython setup warning: No soundfont found.")
68
+ auto = os.getenv("CP_AUTO_DOWNLOAD") == "1"
69
+
70
+ # ask user for permission to download soundfont
71
+ if auto or input("Download the default soundfont now? [Y/n] ").strip().lower() in ("", "y", "yes"):
72
+ path = download_soundfont()
73
+ print(f"Downloaded to: {path}")
74
+
75
+ # otherwise, instruct them how to add their own
76
+ else:
77
+ print(f"\nPlace your .sf2 soundfont at:\n {SOUNDFONT_PATH}\nOr set CREATIVEPYTHON_SOUNDFONT to its location in your PATH.")
78
+ print("\n(see https://pypi.org/project/CreativePython/ for more details)")
79
+
80
+
81
+ def playNote():
82
+ from music import Note, Play, C4, HN # can't use * within function, so naming needed pieces
83
+
84
+ note = Note(C4, HN) # create a middle C half note
85
+ Play.midi(note) # and play it!
@@ -981,14 +981,23 @@ class Display(Interactable):
981
981
 
982
982
  if type.endswith("Press"): # press -> mouseDown
983
983
  self.lastMouseDown = (x, y)
984
- self._event("mouseDown", [x, y]) # deliver mouseDown to display
985
984
 
986
- if self.hoverItem is not None: # is there a hover item?
987
- self.hoverItem._event("mouseDown", [x, y]) # yes, deliver mouseDown to it
988
- self.focusItem = self.hoverItem # then, promote hover item to focus item
985
+ # determine item under cursor at press-time for correct focus
986
+ pressedItem = None
987
+ i = 0
988
+ while pressedItem is None and i < len(self.items):
989
+ item = self.items[i]
990
+ if item.contains(x, y):
991
+ pressedItem = item
992
+ i += 1
993
+
994
+ # set focus based on press location
995
+ self.focusItem = pressedItem
989
996
 
990
- else:
991
- self.focusItem = None # no hover item, so no focus item
997
+ # deliver mouseDown: always to display, and to focused item if any
998
+ self._event("mouseDown", [x, y]) # deliver mouseDown to display
999
+ if self.focusItem is not None:
1000
+ self.focusItem._event("mouseDown", [x, y])
992
1001
  # print(f"Mouse pressed at ({x}, {y})")
993
1002
 
994
1003
 
@@ -1004,13 +1013,15 @@ class Display(Interactable):
1004
1013
  if isMouseClick: # and, if this was a click
1005
1014
  self._event("mouseClick", [x, y]) # also deliver mouseClick to display
1006
1015
 
1007
- if self.hoverItem is not None: # is there a hover item?
1008
- self.hoverItem._event("mouseUp", [x, y]) # yes, deliver mouseUp to hover item
1009
- if isMouseClick: # and, if this was a click
1010
- self.hoverItem._event("mouseClick", [x, y]) # also deliver mouseClick to hover item
1016
+ # deliver to the item that was focused at press-time
1017
+ if self.focusItem is not None: # is there a focus item?
1018
+ self.focusItem._event("mouseUp", [x, y]) # yes, deliver mouse up to focus item
1019
+
1020
+ if isMouseClick: # is this a mouse click?
1021
+ self.focusItem._event("mouseClick", [x, y]) # yes, deliver cilck to focus item
1011
1022
 
1012
- else: # no hover item when mouse released, so no focus item
1013
- self.focusItem = None
1023
+ # clear focus on release
1024
+ self.focusItem = None
1014
1025
 
1015
1026
  self.lastMouseDown = None # reset last mouse down position
1016
1027
  # print(f"Mouse released at ({x}, {y})")
@@ -1035,35 +1046,33 @@ class Display(Interactable):
1035
1046
  if dx > self.moveThreshold or dy > self.moveThreshold: # is it outside threshold?
1036
1047
  isMouseDrag = True # yes, this is a mouseDrag
1037
1048
 
1038
- hoverItem = None # look for a hover item
1039
- i = 0
1040
- while hoverItem is None and i < len(self.items):
1041
- item = self.items[i]
1042
- if item.contains(x, y):
1043
- hoverItem = item
1044
- i += 1
1045
-
1046
- if hoverItem != self.hoverItem: # if hover item has changed,
1047
- if self.hoverItem is not None: # was there an old hover item?
1048
- self.hoverItem._event("mouseExit", [x, y]) # yes, deliver mouseExit to old hover item
1049
+ # while dragging we avoid changing hover/focus behavior based on items under the cursor
1050
+ if not isMouseDrag:
1051
+ hoverItem = None # look for a hover item
1052
+ i = 0
1053
+ while hoverItem is None and i < len(self.items):
1054
+ item = self.items[i]
1055
+ if item.contains(x, y):
1056
+ hoverItem = item
1057
+ i += 1
1049
1058
 
1050
- if hoverItem is not None: # is there a new hover item?
1051
- hoverItem._event("mouseEnter", [x, y]) # yes, deliver mouseEnter to new hover item
1059
+ if hoverItem != self.hoverItem: # if hover item has changed,
1060
+ if self.hoverItem is not None: # was there an old hover item?
1061
+ self.hoverItem._event("mouseExit", [x, y]) # yes, deliver mouseExit to old hover item
1052
1062
 
1053
- self.hoverItem = hoverItem # either way, set new hover item
1063
+ if hoverItem is not None: # is there a new hover item?
1064
+ hoverItem._event("mouseEnter", [x, y]) # yes, deliver mouseEnter to new hover item
1054
1065
 
1055
- else: # hover item has not changed
1056
- pass
1066
+ self.hoverItem = hoverItem # either way, set new hover item
1057
1067
 
1058
1068
 
1059
1069
  if isMouseDrag: # if dragging, deliver mouseDrag instead of mouseMove
1060
- self._event("mouseDrag", [x, y]) # deliver mouseDrag to display
1061
-
1062
- if self.focusItem is not None: # is there a focus item?
1063
- self.focusItem._event("mouseDrag", [x, y]) # yes, deliver mouseDrag to focus item
1064
-
1065
- elif self.hoverItem is not None: # ... or is there a hover item?
1066
- self.hoverItem._event("mouseDrag", [x, y]) # yes, deliver mouseDrag to hover item
1070
+ # when an item has focus, do not drag the display or other items
1071
+ if self.focusItem is not None:
1072
+ self.focusItem._event("mouseDrag", [x, y])
1073
+ else:
1074
+ # no focused item: drag events go to display only
1075
+ self._event("mouseDrag", [x, y])
1067
1076
 
1068
1077
 
1069
1078
  else: # otherwise, deliver mouseMove
@@ -1601,6 +1610,41 @@ class Oval(Drawable, Interactable):
1601
1610
  return f'Oval({self.getX()}, {self.getY()}, {x2}, {y2}, {self.getColor()}, {self.fill}, {self.getThickness()}, {self.getRotation()})'
1602
1611
 
1603
1612
 
1613
+ def contains(self, x, y):
1614
+ """Precise hit-test for ellipse.
1615
+ - Always returns True when point is inside the ellipse area (regardless of fill).
1616
+ - Additionally, for unfilled shapes, returns True when the point is near the outline (ring thickness).
1617
+ """
1618
+ if not isinstance(x, (int, float)) or not isinstance(y, (int, float)):
1619
+ raise TypeError(f'Oval.contains(): x and y must be numbers (they were {type(x)} and {type(y)})')
1620
+
1621
+ if self.width == 0 or self.height == 0:
1622
+ return False
1623
+
1624
+ # center and radii
1625
+ cx = self.cornerX + self.width / 2.0
1626
+ cy = self.cornerY + self.height / 2.0
1627
+ rx = self.width / 2.0
1628
+ ry = self.height / 2.0
1629
+
1630
+ # normalize point to ellipse space
1631
+ nx = (x - cx) / rx
1632
+ ny = (y - cy) / ry
1633
+ value = nx*nx + ny*ny # <= 1.0 means inside filled ellipse
1634
+
1635
+ # always accept interior clicks for interaction
1636
+ if value <= 1.0:
1637
+ return True
1638
+
1639
+ # outline-only: accept a ring around the perimeter proportional to thickness
1640
+ # approximate thickness in normalized units using the larger radius as scale
1641
+ scale = max(rx, ry)
1642
+ normalizedThickness = max(self.thickness, 2) / max(scale, 1.0)
1643
+ inner = 1.0 - normalizedThickness
1644
+ outer = 1.0 + normalizedThickness
1645
+ return inner <= value <= outer
1646
+
1647
+
1604
1648
  class Circle(Oval):
1605
1649
 
1606
1650
  def __init__(self, x, y, radius, color=Color.BLACK, fill=False, thickness=1, rotation=0):
@@ -931,7 +931,7 @@ def _stopActiveMidiObjects():
931
931
  _activeMidiInObjects.clear()
932
932
  _activeMidiOutObjects.clear()
933
933
 
934
- print("All MIDI devices closed.")
934
+ # print("All MIDI devices closed.")
935
935
 
936
936
  # register the cleanup function to be called when the program exits
937
937
  atexit.register(_stopActiveMidiObjects)
@@ -1,103 +0,0 @@
1
- # CreativePython
2
-
3
- CreativePython is a Python-based software environment for developing algorithmic art projects. It mirrors the [JythonMusic API](https://jythonmusic.me/api-reference/).
4
-
5
- This package is still under development.
6
-
7
- ---
8
-
9
- ## Quick Install
10
-
11
- The CreativePython Install Scripts [(Download)](https://www.dropbox.com/scl/fo/7cwxayca38ajcc533bpgs/AGP4pnP-xhb-5LH_7YPsgyk?rlkey=2led17m6h0ku9y3hzbsnvsio1&dl=1) install CreativePython and all its required software, including Python3, FluidSynth, PortAudio, ffmpeg, Homebrew (on Mac), and Windows Build Kit (on Windows).
12
-
13
- ### Windows
14
- 1. Open `win-scripts.tgz`. Right-click `windows_setup.bat`, and **Run as Administrator** (it will open PowerShell and run).
15
- 2. Follow any prompts and let it finish.
16
- - If you do not have Windows Build Kit installed, it will be installed as part of this process. This may take some time to complete.
17
-
18
- ### macOS
19
- 1. Open `mac-scripts.tgz`. Control-click `mac_setup.command`, and **Open** (it will open Terminal and run).
20
- 2. Follow any prompts and let it finish.
21
- - If you do not have Command Line Tools for XCode installed, it will be installed as part of this process. This may take some time to complete.
22
-
23
- ---
24
-
25
- ## Custom Install
26
-
27
- ---
28
-
29
- ### 1. Install Python 3 + pip
30
-
31
- #### Windows
32
- 1. Download the [Python 3 installer](https://www.python.org/downloads/).
33
- 2. Run the installer. **Check the box that says “Add Python to PATH”** before clicking *Install Now*.
34
- 3. Open Command Prompt (search for "cmd" in the Start menu).
35
- 4. Verify your installation.
36
-
37
- ```$ python --version```
38
-
39
- You should see something like "Python 3.12.4"
40
-
41
- #### MacOS
42
- 1. Open Terminal (press Command + Space, type "Terminal", and hit Enter).
43
- 2. Install **Homebrew** if you don't have it.
44
-
45
- ```$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"```
46
-
47
- 3. Install Python 3.
48
-
49
- ```$ brew install python```
50
-
51
- 4. Verify your installation.
52
-
53
- ```$ python3 --version```
54
-
55
- You should see something like "Python 3.12.4"
56
-
57
- ---
58
-
59
- ### 2. Install System Libraries
60
-
61
- #### Windows
62
- - **PortAudio**:
63
- On Windows, PortAudio is installed automatically with CreativePython, however you need Microsoft Build Tools installed first.
64
- 1. Download [the latest Windows build](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
65
- 2. Run the installer. When prompted, select **C++ build tools**.
66
- 3. Click **Install**. This may take several minutes.
67
-
68
- - **FluidSynth**:
69
- 1. Download [the latest Windows build](https://github.com/FluidSynth/fluidsynth/releases).
70
- 2. Unzip it, and add the folder's location to your PATH.
71
-
72
- - **ffmpeg**:
73
- 1. Download [the latest Windows build](ffmpeg.org/download.html).
74
- 2. Unzip it, and move the folder to `C:\ffmpeg`.
75
- 3. Add `C:\ffmpeg\bin` to your PATH.
76
-
77
- #### Mac
78
- - **All Libraries**:
79
- 1. Open Terminal.
80
- 2. Install PortAudio, FluidSynth, and ffmpeg.
81
-
82
- ```$ brew install portaudio fluidsynth ffmpeg```
83
-
84
- ---
85
-
86
- ### 3. Install CreativePython
87
-
88
- #### Any OS
89
- 1. Open Command Prompt/Terminal.
90
-
91
- ```$ pip install CreativePython```
92
-
93
- ```$ cp-setup```
94
-
95
- 2. When prompted, download the default soundfont. (It's FluidR3 GM2-2, by the way)
96
-
97
- - If you choose not to download the soundfont, you will need to provide your own.
98
-
99
- 3. Verify your installation.
100
-
101
- ```$ cp-test```
102
-
103
- You should hear a single MIDI note played at C4. If so, you're all set!
@@ -1,101 +0,0 @@
1
- ### SOUNDFONT DOWNLOAD HELPERS
2
-
3
- from __future__ import annotations
4
- from pathlib import Path
5
- from platformdirs import user_data_dir
6
-
7
- APP = "CreativePython"
8
- ORG = "CofC"
9
-
10
- SOUNDFONT_NAME = "default.sf2"
11
- CACHE_DIR = Path(user_data_dir(APP, ORG)) / "SoundFonts"
12
- SOUNDFONT_PATH = CACHE_DIR / SOUNDFONT_NAME
13
-
14
- SF2_URL = "https://www.dropbox.com/s/xixtvox70lna6m2/FluidR3%20GM2-2.SF2?dl=1"
15
- SF2_SHA256 = "2ae766ab5c5deb6f7fffacd6316ec9f3699998cce821df3163e7b10a78a64066"
16
-
17
- def find_soundfont(explicit: str | None = None) -> Path | None:
18
- """
19
- Finds a soundfont 'default.sf2' in the cache, and returns its location.
20
- explicit can be another path that may have the soundfont needed.
21
- """
22
- import os
23
-
24
- candidates = []
25
- if explicit:
26
- candidates.append(Path(explicit))
27
- env = os.getenv("CREATIVEPYTHON_SOUNDFONT")
28
- if env:
29
- candidates.append(Path(env))
30
- candidates += [SOUNDFONT_PATH, Path.home() / "SoundFonts" / SOUNDFONT_NAME]
31
- for c in candidates:
32
- if c and c.exists():
33
- return str(c)
34
- return None
35
-
36
- def download_soundfont(dest: Path = SOUNDFONT_PATH) -> Path:
37
- """Downloads a default soundfont and saves it to the user's cache."""
38
- from pooch import retrieve, Unzip
39
- dest.parent.mkdir(parents=True, exist_ok=True)
40
- p = retrieve(url=SF2_URL, known_hash=f"sha256:{SF2_SHA256}", progressbar=True, fname=dest.name, path=str(dest.parent))
41
- return Path(p)
42
-
43
-
44
-
45
- ### AUTOMATIC CHECK METHODS
46
-
47
- def run():
48
- import shutil, sys, os
49
- missing = []
50
-
51
- # Check for soundfont file
52
- sf = find_soundfont()
53
-
54
- # Attempt to download missing soundfont
55
- if not sf:
56
- print("CreativePython setup warning: No soundfont found.")
57
- auto = os.getenv("CP_AUTO_DOWNLOAD") == "1"
58
- if auto or input("Download the default soundfont now? [Y/n] ").strip().lower() in ("", "y", "yes"):
59
- path = download_soundfont()
60
- print(f"Downloaded to: {path}")
61
- else:
62
- print(f"\nPlace your .sf2 soundfont at:\n {SOUNDFONT_PATH}\nOr set CREATIVEPYTHON_SOUNDFONT to its location in your PATH.")
63
- print("\n(see https://pypi.org/project/CreativePython/ for more details)")
64
-
65
-
66
- # Check for required installations
67
- if not shutil.which("ffmpeg"):
68
- missing.append("ffmpeg")
69
-
70
- if not shutil.which("fluidsynth"):
71
- missing.append("FluidSynth")
72
-
73
- if not shutil.which("portaudio"):
74
- missing.append("PortAudio")
75
-
76
- # Warn user about missing requirements
77
- if missing:
78
- print("\nCreativePython setup warning:")
79
- for req in missing:
80
- print(f" - {req} is not installed.")
81
-
82
- if sys.platform.startswith("darwin"):
83
- print("\nOn macOS, run:\n brew install portaudio fluidsynth ffmpeg")
84
- elif sys.platform.startswith("win"):
85
- print("\nOn Windows, install missing packages from developers, or run windows_setup.bat")
86
- else:
87
- print("\nOn Linux, install missing packages with your package manager (apt, dnf, etc.)")
88
-
89
- print("\n(see https://pypi.org/project/CreativePython/ for more details)")
90
-
91
- return len(missing) == 0
92
-
93
-
94
- def playNote():
95
- ready = run() # check for installation dependencies
96
-
97
- if ready:
98
- from music import Note, Play, C4, HN # can't use * within function, so naming needed pieces
99
-
100
- note = Note(C4, HN) # create a middle C half note
101
- Play.midi(note) # and play it!
File without changes
File without changes