Commit
·
a8cb0a6
0
Parent(s):
initial commit
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .dockerignore +4 -0
- .gitattributes +42 -0
- .gitignore +4 -0
- Audios/AriaMath/original.m4a +0 -0
- Audios/AriaMath/processed-mean.mp3 +3 -0
- Audios/AriaMath/result-mean.pkl +3 -0
- Audios/DilKyuYeMera/original.mp3 +3 -0
- Audios/DilKyuYeMera/processed-mean.mp3 +3 -0
- Audios/DilKyuYeMera/result-mean.pkl +3 -0
- Audios/GhibliBeats/original.m4a +0 -0
- Audios/GhibliBeats/processed-Max.mp3 +3 -0
- Audios/GhibliBeats/processed-Mean.mp3 +3 -0
- Audios/GhibliBeats/result-Max.pkl +3 -0
- Audios/GhibliBeats/result-Mean.pkl +3 -0
- Audios/PiratesOfCarribean/original.mp3 +3 -0
- Audios/PiratesOfCarribean/processed-mean.mp3 +3 -0
- Audios/PiratesOfCarribean/result-mean.pkl +3 -0
- Audios/RiverFlowsInYou/original.m4a +0 -0
- Audios/RiverFlowsInYou/processed-Mean.mp3 +3 -0
- Audios/RiverFlowsInYou/result-Mean.pkl +3 -0
- Audios/TetrisBeats/original.m4a +0 -0
- Audios/TetrisBeats/processed-Mean.mp3 +3 -0
- Audios/TetrisBeats/result-Mean.pkl +3 -0
- Dockerfile +21 -0
- ExtraSounds/AsfAmplitudeCalculatingWithGap.m4a +0 -0
- ExtraSounds/AsfAmplitudeCheckingWithoutGap.m4a +0 -0
- ExtraSounds/InstrumentsBaseSoundsRecorded.m4a +0 -0
- ExtraSounds/KneeSocks.m4a +3 -0
- ExtraSounds/gettysburg.wav +3 -0
- ExtraSounds/lofiBeats.m4a +3 -0
- MusicAnalyzer/Instruments/banjo.ogg +3 -0
- MusicAnalyzer/Instruments/bass.ogg +3 -0
- MusicAnalyzer/Instruments/bdrum.ogg +3 -0
- MusicAnalyzer/Instruments/bell.ogg +3 -0
- MusicAnalyzer/Instruments/bit.ogg +3 -0
- MusicAnalyzer/Instruments/chimes.ogg +3 -0
- MusicAnalyzer/Instruments/cow_bell.ogg +3 -0
- MusicAnalyzer/Instruments/didgeridoo.ogg +3 -0
- MusicAnalyzer/Instruments/flute.ogg +3 -0
- MusicAnalyzer/Instruments/guitar.ogg +3 -0
- MusicAnalyzer/Instruments/harp.ogg +3 -0
- MusicAnalyzer/Instruments/hat.ogg +3 -0
- MusicAnalyzer/Instruments/iron_xylophone.ogg +3 -0
- MusicAnalyzer/Instruments/pling.ogg +3 -0
- MusicAnalyzer/Instruments/snare.ogg +3 -0
- MusicAnalyzer/Instruments/xylophone.ogg +3 -0
- MusicAnalyzer/RajatsMinecraftLibrary/amplitude.py +114 -0
- MusicAnalyzer/RajatsMinecraftLibrary/audio.py +186 -0
- MusicAnalyzer/RajatsMinecraftLibrary/minecraft.py +297 -0
- MusicAnalyzer/RajatsMinecraftLibrary/test.py +64 -0
.dockerignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
**/.DS_Store
|
2 |
+
**/__pycache__
|
3 |
+
node_modules
|
4 |
+
**/.vscode
|
.gitattributes
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
39 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
40 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
41 |
+
ExtraSounds/KneeSocks.m4a filter=lfs diff=lfs merge=lfs -text
|
42 |
+
ExtraSounds/lofiBeats.m4a filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
**/.DS_Store
|
2 |
+
**/__pycache__
|
3 |
+
node_modules
|
4 |
+
**/.vscode
|
Audios/AriaMath/original.m4a
ADDED
Binary file (328 kB). View file
|
|
Audios/AriaMath/processed-mean.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c1163b83102bbaf5b0fe226548f768ab103f671d66bf21ee1fa6ce02c02e1299
|
3 |
+
size 154481
|
Audios/AriaMath/result-mean.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:faa2b572d2ac8801d41225d83aa41b81859ccfc551704d22fa16ff07b191487e
|
3 |
+
size 27759
|
Audios/DilKyuYeMera/original.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d2adb64e9c774b80b7ef3fdbb93fc9b58cfc64ba02d743c4423ff6363417b412
|
3 |
+
size 234237
|
Audios/DilKyuYeMera/processed-mean.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0154c7575654564e583797e64ead00f74c91d06ef7bafce169929d579c0f2229
|
3 |
+
size 129733
|
Audios/DilKyuYeMera/result-mean.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:94ad2e21eca5590be3b0a9af0c380dc72376fab3ea1d96f4dbf66d8b4287e752
|
3 |
+
size 24633
|
Audios/GhibliBeats/original.m4a
ADDED
Binary file (276 kB). View file
|
|
Audios/GhibliBeats/processed-Max.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c6f54c2b42e67072f7a50916502a1929d8dff7d53600b01165c0c72f3c57fd7e
|
3 |
+
size 74559
|
Audios/GhibliBeats/processed-Mean.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:797aa050347e06103aade3af6afbb675284f9cf98bb692b43895d4aee69e0615
|
3 |
+
size 83223
|
Audios/GhibliBeats/result-Max.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:646a6c438eea5262f0b73d5670791caf43e8f3d7fe9fbc354089a601f1dee8e6
|
3 |
+
size 12413
|
Audios/GhibliBeats/result-Mean.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ef61cbec7e130cae0538a8cf644222893256190d08bd4027c488c47896990649
|
3 |
+
size 15053
|
Audios/PiratesOfCarribean/original.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1c3d6a50549237218c7be886144fc8aaf32f0ae5366b1cc5d4f6743fd899e707
|
3 |
+
size 558189
|
Audios/PiratesOfCarribean/processed-mean.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4a9ebb7674e386867cca4071138bb5b77e2f0e6a3cc3f986b45792e0a4511c64
|
3 |
+
size 205754
|
Audios/PiratesOfCarribean/result-mean.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b35300d3f6bab53b2670b1af0ec9dae19071604ca04b4e1c81c0c409051c385c
|
3 |
+
size 41112
|
Audios/RiverFlowsInYou/original.m4a
ADDED
Binary file (121 kB). View file
|
|
Audios/RiverFlowsInYou/processed-Mean.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ca10be23fc408bb25923941be5d3d47ecf3247539eb263b2c7c7cdf88e7783f9
|
3 |
+
size 98446
|
Audios/RiverFlowsInYou/result-Mean.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85b33ce601cfd0c56db9ae07c5ef2cd370801f6ffef0e22eb39991488a243c75
|
3 |
+
size 19862
|
Audios/TetrisBeats/original.m4a
ADDED
Binary file (479 kB). View file
|
|
Audios/TetrisBeats/processed-Mean.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6409eb6ee4e4dffa7640145983b8b255e1be351156442a7fe752b7a373187ab7
|
3 |
+
size 58584
|
Audios/TetrisBeats/result-Mean.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8f69d540e66a101eefd64ffeed2f03d4f9bc05e19dcf2912bd23adade2cb8246
|
3 |
+
size 13963
|
Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# syntax=docker/dockerfile:1
|
2 |
+
|
3 |
+
FROM python:3.12-slim
|
4 |
+
RUN useradd -m -u 1000 user
|
5 |
+
WORKDIR /minecraft-noteblock-music-generator
|
6 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
7 |
+
|
8 |
+
RUN apt-get update && \
|
9 |
+
apt-get install -y ffmpeg && \
|
10 |
+
apt-get clean && \
|
11 |
+
rm -rf /var/lib/apt/lists/*
|
12 |
+
|
13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
14 |
+
COPY --chown=user . .
|
15 |
+
|
16 |
+
# RUN chown -R choreouser:choreo /usr/local/lib/python3.12/site-packages
|
17 |
+
# USER 10014
|
18 |
+
# EXPOSE 8080
|
19 |
+
|
20 |
+
CMD ["python3", "app.py"]
|
21 |
+
# CMD ["gunicorn", "app:app", "-b", "0.0.0.0:7860"]
|
ExtraSounds/AsfAmplitudeCalculatingWithGap.m4a
ADDED
Binary file (132 kB). View file
|
|
ExtraSounds/AsfAmplitudeCheckingWithoutGap.m4a
ADDED
Binary file (336 kB). View file
|
|
ExtraSounds/InstrumentsBaseSoundsRecorded.m4a
ADDED
Binary file (671 kB). View file
|
|
ExtraSounds/KneeSocks.m4a
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3441b724f6cbe51cc6ede2ed277b47113914f4d077842b1d1d1cc0c623f5f87d
|
3 |
+
size 1739305
|
ExtraSounds/gettysburg.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7630daffb2f28f2724d81f1ff2039eb69a5fa360db3919721a77032a58db0d46
|
3 |
+
size 775192
|
ExtraSounds/lofiBeats.m4a
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:18572b2b08aa8577cd48562e429dc4df5e0b25c03b5779d468be7ea5eeabc312
|
3 |
+
size 1005582
|
MusicAnalyzer/Instruments/banjo.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:06b4e1927947bf2152d2d552099f753b2842f2419632f8effa1bad48d03af5f7
|
3 |
+
size 12499
|
MusicAnalyzer/Instruments/bass.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7261568b63fea6a5763335479d16980329ae0c8db35f1b743eb86005d1a12150
|
3 |
+
size 5574
|
MusicAnalyzer/Instruments/bdrum.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:829e1ff33546ef3de4e1e1a38ca3e0dc8a582227c284052868963333ed790686
|
3 |
+
size 3850
|
MusicAnalyzer/Instruments/bell.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:550f0027fbaf52e1046898c05b65b9690d9db5374603fb701e5bd995f0d1059e
|
3 |
+
size 5827
|
MusicAnalyzer/Instruments/bit.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6f5948e882931aaaab6a2396e0fb77228929481150fc0b822e4ac0d4c6c3bcfb
|
3 |
+
size 11872
|
MusicAnalyzer/Instruments/chimes.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9c8cc11b9f7e57d5645fd91cb2270b765067f3c01a064228b3ca6dc88bd188e7
|
3 |
+
size 8606
|
MusicAnalyzer/Instruments/cow_bell.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a18c945ff55914a4f51ddf6ecb012140cc737e63931947377c940e0d66474b7
|
3 |
+
size 8428
|
MusicAnalyzer/Instruments/didgeridoo.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7eaecdb39733fa5d1db91ec93fdc745a2cff9d0d77afdcbcfa9bc12568d542aa
|
3 |
+
size 12012
|
MusicAnalyzer/Instruments/flute.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9372c07a7b9939d54ba877e25ba162806143b143bd05983f2bdc0a35c913fcbe
|
3 |
+
size 8781
|
MusicAnalyzer/Instruments/guitar.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8c15ed51b6fd1724e1fcc532d916961ca7925ccb0538cb7464eb84f747633469
|
3 |
+
size 7563
|
MusicAnalyzer/Instruments/harp.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d775e11718dba8dd601e76bee5958aa02ed0d56c26481881d4c28226f7bd4477
|
3 |
+
size 6137
|
MusicAnalyzer/Instruments/hat.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8139400f63c0bc7114e960826a11bb1cd561e8f0c01dce077dbc6424ae51ab6c
|
3 |
+
size 3880
|
MusicAnalyzer/Instruments/iron_xylophone.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0a7ef8406f4ad4c5037aa1ecb7a9bf02cf34e86bb0bea46596eef147458b156a
|
3 |
+
size 9559
|
MusicAnalyzer/Instruments/pling.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d7e3638d4c0fba4614f24ba94d6380935ae2341536d76989e44f00ffd94a1459
|
3 |
+
size 6274
|
MusicAnalyzer/Instruments/snare.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a2a5168e70548dcddd5015204cec586365e611854e83bf634b42f2a6ddd8c3b7
|
3 |
+
size 3969
|
MusicAnalyzer/Instruments/xylophone.ogg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bd9c7af0c25f7033bff3026f6133e33d7b4d26d5ab689b66376cae090df95dd0
|
3 |
+
size 4551
|
MusicAnalyzer/RajatsMinecraftLibrary/amplitude.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import matplotlib.pyplot as plt
|
2 |
+
import librosa
|
3 |
+
|
4 |
+
|
5 |
+
class AsfPosConverter:
|
6 |
+
@staticmethod
|
7 |
+
def getPosition(amplitude_dict, curr_amp):
|
8 |
+
closest_key = None
|
9 |
+
closest_diff = float("inf")
|
10 |
+
|
11 |
+
for key, _ in amplitude_dict.items():
|
12 |
+
diff = abs(float(key) - curr_amp)
|
13 |
+
if diff < closest_diff:
|
14 |
+
closest_key = key
|
15 |
+
closest_diff = diff
|
16 |
+
|
17 |
+
return closest_key, amplitude_dict[closest_key]
|
18 |
+
|
19 |
+
@staticmethod
|
20 |
+
def getAmplitude(amplitude_dict, curr_pos):
|
21 |
+
diff = float('inf')
|
22 |
+
res = None
|
23 |
+
for key, value in amplitude_dict.items():
|
24 |
+
if abs(float(value) - curr_pos) < diff:
|
25 |
+
res = float(key)
|
26 |
+
diff = abs(float(value) - curr_pos)
|
27 |
+
return res
|
28 |
+
|
29 |
+
# @staticmethod
|
30 |
+
# def analyze(audio_file):
|
31 |
+
# amplitude_list, _ = librosa.load(audio_file)
|
32 |
+
# plt.plot(amplitude_list)
|
33 |
+
# plt.show()
|
34 |
+
|
35 |
+
# # IDENTIFY THE BELOW VALUES BY HOVERING THE CURSOR OVER MATPLOTLIB PLOT
|
36 |
+
# # amplitude_list = [0.155, 0.152, 0.149, 0.145, 0.143, 0.139, 0.134, 0.130, 0.121, 0.115, 0.108, 0.094, 0.089, 0.075, 0.054, 0.036, 0.016, 0]
|
37 |
+
|
38 |
+
# # ----- AMPLITUDE LIST AVERAGING ---------
|
39 |
+
# # amplitude_list_copy = [1]
|
40 |
+
# # for i in range(1, len(amplitude_list)-1):
|
41 |
+
# # amplitude_list_copy.append(round((amplitude_list[i-1] + amplitude_list[i] + amplitude_list[i+1])/3, 5))
|
42 |
+
# # # print("Max Amplitude:", max_amplitude)
|
43 |
+
# # amplitude_list_copy.append(0)
|
44 |
+
# # amplitude_list = amplitude_list_copy
|
45 |
+
# # ----- AMPLITUDE LIST SCALING ---------
|
46 |
+
# # amplitude_list_copy = []
|
47 |
+
# # for amp in amplitude_list:
|
48 |
+
# # amplitude_list_copy.append(round(amp / amplitude_list[0], 4))
|
49 |
+
# # print(amplitude_list_copy)
|
50 |
+
# # ----- AMPLITUDE LIST PLOTTING ---------
|
51 |
+
# # plt.plot(amplitude_list_copy)
|
52 |
+
# # plt.show()
|
53 |
+
# # ---------------------------------------
|
54 |
+
|
55 |
+
# amplitude_list = [
|
56 |
+
# 1,
|
57 |
+
# 0.99,
|
58 |
+
# 0.98,
|
59 |
+
# 0.97,
|
60 |
+
# 0.97,
|
61 |
+
# 0.96,
|
62 |
+
# 0.95,
|
63 |
+
# 0.95,
|
64 |
+
# 0.94,
|
65 |
+
# 0.93,
|
66 |
+
# 0.93,
|
67 |
+
# 0.92,
|
68 |
+
# 0.91,
|
69 |
+
# 0.91,
|
70 |
+
# 0.9,
|
71 |
+
# 0.89,
|
72 |
+
# 0.88,
|
73 |
+
# 0.87,
|
74 |
+
# 0.86,
|
75 |
+
# 0.845,
|
76 |
+
# 0.83,
|
77 |
+
# 0.815,
|
78 |
+
# 0.8,
|
79 |
+
# 0.79,
|
80 |
+
# 0.775,
|
81 |
+
# 0.76,
|
82 |
+
# 0.74,
|
83 |
+
# 0.72,
|
84 |
+
# 0.7,
|
85 |
+
# 0.68,
|
86 |
+
# 0.66,
|
87 |
+
# 0.64,
|
88 |
+
# 0.62,
|
89 |
+
# 0.6,
|
90 |
+
# 0.57,
|
91 |
+
# 0.54,
|
92 |
+
# 0.515,
|
93 |
+
# 0.49,
|
94 |
+
# 0.47,
|
95 |
+
# 0.43,
|
96 |
+
# 0.39,
|
97 |
+
# 0.35,
|
98 |
+
# 0.31,
|
99 |
+
# 0.27,
|
100 |
+
# 0.23,
|
101 |
+
# 0.19,
|
102 |
+
# 0.15,
|
103 |
+
# 0.11,
|
104 |
+
# 0,
|
105 |
+
# ]
|
106 |
+
# print(amplitude_list)
|
107 |
+
|
108 |
+
|
109 |
+
if __name__ == "__main__":
|
110 |
+
print(
|
111 |
+
"This is a library for Audio Manipulation via fourier transform made specificaly for minecraft audio production using note blocks"
|
112 |
+
)
|
113 |
+
print("Author -: Rajat Bansal, IIT Mandi, B20123")
|
114 |
+
# AsfToPos.analyze('Sounds/Amplitude2.m4a')
|
MusicAnalyzer/RajatsMinecraftLibrary/audio.py
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import librosa
|
3 |
+
import IPython.display as ipd
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
# import audioread
|
6 |
+
# import time
|
7 |
+
# import soundfile as sf
|
8 |
+
|
9 |
+
# def read_audio(path):
|
10 |
+
# try:
|
11 |
+
# if path[-4:] == '.ogg':
|
12 |
+
# y, sr_native = sf.read(path)
|
13 |
+
# else:
|
14 |
+
# buf = []
|
15 |
+
# with audioread.audio_open(path) as input_file:
|
16 |
+
# sr_native = input_file.samplerate
|
17 |
+
# n_channels = input_file.channels
|
18 |
+
|
19 |
+
# for frame in input_file:
|
20 |
+
# frame = (1.0 / float(1 << 15)) * np.frombuffer(frame, f"<i{2:d}").astype(np.float32)
|
21 |
+
# buf.append(frame)
|
22 |
+
|
23 |
+
# y = np.concatenate(buf)
|
24 |
+
# if n_channels > 1:
|
25 |
+
# y = y.reshape((-1, n_channels)).T
|
26 |
+
# y = np.mean(y, axis=tuple(range(y.ndim - 1)))
|
27 |
+
# y = librosa.resample(y, orig_sr=sr_native, target_sr=22050, res_type="soxr_hq")
|
28 |
+
# return y, 22050
|
29 |
+
|
30 |
+
# except Exception as e:
|
31 |
+
# print(f"Error reading audio file: {e}")
|
32 |
+
# return None, None
|
33 |
+
|
34 |
+
class MyAudio:
|
35 |
+
def __init__(self, details, audioValues):
|
36 |
+
self.details = details
|
37 |
+
self.audioValues = audioValues
|
38 |
+
|
39 |
+
@staticmethod
|
40 |
+
def combineTwoAudios(audio1, audio2):
|
41 |
+
details = audio1.details.copy()
|
42 |
+
details.extend(audio2.details)
|
43 |
+
audioValues = AudioManipulator.joinDiffAudiosValues(
|
44 |
+
[audio1.audioValues, audio2.audioValues]
|
45 |
+
)
|
46 |
+
return MyAudio(details, audioValues)
|
47 |
+
|
48 |
+
@staticmethod
|
49 |
+
def changeAudioToFFT(audio):
|
50 |
+
return MyAudio(audio.details, librosa.stft(audio.audioValues.copy()))
|
51 |
+
|
52 |
+
@staticmethod
|
53 |
+
def compareTwoFFTAudios(audio1, audio2):
|
54 |
+
audio1Values = np.abs(audio1.audioValues)
|
55 |
+
audio2Values = np.abs(audio2.audioValues)
|
56 |
+
if audio1Values.shape[1] > audio2Values.shape[1]:
|
57 |
+
audio1Values, audio2Values = audio2Values, audio1Values
|
58 |
+
audio2Values = audio2Values[:, : audio1Values.shape[1]]
|
59 |
+
|
60 |
+
norm = np.linalg.norm(audio1Values) * np.linalg.norm(audio2Values)
|
61 |
+
if norm == 0:
|
62 |
+
return 0
|
63 |
+
return np.dot(audio1Values.flatten(), audio2Values.flatten()) / norm
|
64 |
+
|
65 |
+
|
66 |
+
class AudioManipulator:
|
67 |
+
# def __init__(self):
|
68 |
+
# self.n_mels = 128 * 2
|
69 |
+
|
70 |
+
@staticmethod
|
71 |
+
def addAudioValuesInDuration(audioValues1, audioValues2, timeSt, sr):
|
72 |
+
indexSt = min(len(audioValues1) - 1, int(timeSt / 1000 * sr))
|
73 |
+
indexEd = min(len(audioValues1), indexSt + len(audioValues2))
|
74 |
+
for index in range(indexSt, indexEd):
|
75 |
+
audioValues1[index] += audioValues2[index - indexSt]
|
76 |
+
return audioValues1
|
77 |
+
|
78 |
+
@staticmethod
|
79 |
+
def joinDiffAudiosValues(audiosValues):
|
80 |
+
mx = -1
|
81 |
+
for i in range(len(audiosValues)):
|
82 |
+
mx = max(mx, len(audiosValues[i]))
|
83 |
+
for i in range(len(audiosValues)):
|
84 |
+
if len(audiosValues[i]) < mx:
|
85 |
+
audiosValues[i] = np.concatenate(
|
86 |
+
(audiosValues[i], np.zeros(int(mx - len(audiosValues[i]))))
|
87 |
+
)
|
88 |
+
return np.sum(audiosValues, axis=0)
|
89 |
+
|
90 |
+
@staticmethod
|
91 |
+
def getAudioValuesInterface(audioValues):
|
92 |
+
return ipd.Audio(audioValues)
|
93 |
+
|
94 |
+
@staticmethod
|
95 |
+
def splitAudioValues(audioValues, sr, start_time, end_time):
|
96 |
+
audioValues = audioValues[
|
97 |
+
int(sr * start_time / 1000) : int(sr * end_time / 1000)
|
98 |
+
]
|
99 |
+
return audioValues
|
100 |
+
|
101 |
+
@staticmethod
|
102 |
+
def shiftPitchOfAudioValues(audioValues, sr, pitch_shift):
|
103 |
+
audio_with_pitch_shift = librosa.effects.pitch_shift(
|
104 |
+
audioValues, sr=sr, n_steps=pitch_shift
|
105 |
+
)
|
106 |
+
return audio_with_pitch_shift
|
107 |
+
|
108 |
+
@staticmethod
|
109 |
+
def calculateAmplitudeShiftOfAudioValues(audioValues1, audioValues2, mode):
|
110 |
+
if mode == "Max":
|
111 |
+
peak_amplitude1 = np.max(np.abs(audioValues1))
|
112 |
+
peak_amplitude2 = np.max(np.abs(audioValues2))
|
113 |
+
elif mode == "Mean":
|
114 |
+
peak_amplitude1 = np.mean(np.abs(audioValues1))
|
115 |
+
peak_amplitude2 = np.mean(np.abs(audioValues2))
|
116 |
+
|
117 |
+
scaling_factor = peak_amplitude1 / peak_amplitude2
|
118 |
+
return round(scaling_factor, 2)
|
119 |
+
|
120 |
+
@staticmethod
|
121 |
+
def getStftAndStftDb(audioValues):
|
122 |
+
stft = librosa.stft(audioValues)
|
123 |
+
stft_db = librosa.amplitude_to_db(abs(stft))
|
124 |
+
return stft, stft_db
|
125 |
+
|
126 |
+
@staticmethod
|
127 |
+
def getMelSpectogram(audioValues, sr):
|
128 |
+
mel_spec = librosa.feature.melspectrogram(
|
129 |
+
y=audioValues, sr=sr, n_mels=128*2
|
130 |
+
)
|
131 |
+
mel_spec_db = librosa.amplitude_to_db(mel_spec) # ref = np.max
|
132 |
+
return mel_spec, mel_spec_db
|
133 |
+
|
134 |
+
@staticmethod
|
135 |
+
def getChromaGram(audioValues, sr):
|
136 |
+
chromaGram = librosa.feature.chroma_stft(
|
137 |
+
y=audioValues, sr=sr, hop_length=12
|
138 |
+
)
|
139 |
+
return chromaGram
|
140 |
+
|
141 |
+
@staticmethod
|
142 |
+
def drawAudioValues(audioValues, sr):
|
143 |
+
plt.figure(figsize=(8.8, 3))
|
144 |
+
plt.plot([(i + 1) / sr for i in range(len(audioValues))], audioValues)
|
145 |
+
plt.title("Raw Audio Example")
|
146 |
+
plt.show()
|
147 |
+
|
148 |
+
@staticmethod
|
149 |
+
def drawAudioValuesSpectrum(audioValues, sr):
|
150 |
+
X, Xdb = AudioManipulator.getStft(audioValues)
|
151 |
+
plt.figure(figsize=(14, 5))
|
152 |
+
librosa.display.specshow(Xdb, sr=sr, x_axis="time", y_axis="log")
|
153 |
+
plt.colorbar()
|
154 |
+
plt.show()
|
155 |
+
|
156 |
+
def drawAudioValuesSpectrumNormalized(audioValues, sr):
|
157 |
+
X, Xdb = AudioManipulator.getStft(audioValues / audioValues.max() * 32767.00)
|
158 |
+
plt.figure(figsize=(14, 5))
|
159 |
+
librosa.display.specshow(Xdb, sr=sr, x_axis="time", y_axis="log")
|
160 |
+
plt.colorbar()
|
161 |
+
plt.show()
|
162 |
+
|
163 |
+
@staticmethod
|
164 |
+
def drawMelSpectrogram(audioValues, sr):
|
165 |
+
S, S_db_mel = AudioManipulator.getMelSpectogram(audioValues, sr)
|
166 |
+
|
167 |
+
fig, ax = plt.subplots(figsize=(10, 3))
|
168 |
+
img = librosa.display.specshow(S_db_mel, x_axis="time", y_axis="log", ax=ax)
|
169 |
+
ax.set_title("Mel Spectogram Example", fontsize=20)
|
170 |
+
fig.colorbar(img, ax=ax, format=f"%0.2f")
|
171 |
+
plt.show()
|
172 |
+
|
173 |
+
@staticmethod
|
174 |
+
def drawChromaGram(audioValues, sr):
|
175 |
+
chromagram = AudioManipulator.getChromaGram(audioValues, sr)
|
176 |
+
plt.figure(figsize=(15, 5))
|
177 |
+
librosa.display.specshow(
|
178 |
+
chromagram, x_axis="time", y_axis="chroma", hop_length=12, cmap="coolwarm"
|
179 |
+
)
|
180 |
+
|
181 |
+
|
182 |
+
if __name__ == "__main__":
|
183 |
+
print(
|
184 |
+
"This is a library for Audio Manipulation via fourier transform made specificaly for minecraft audio production using note blocks"
|
185 |
+
)
|
186 |
+
print("Author -: Rajat Bansal, IIT Mandi, B20123")
|
MusicAnalyzer/RajatsMinecraftLibrary/minecraft.py
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from enum import Enum
|
2 |
+
from .amplitude import AsfPosConverter
|
3 |
+
|
4 |
+
|
5 |
+
class space_state(Enum):
|
6 |
+
unavailable = 1
|
7 |
+
available_without_connector = 2
|
8 |
+
default_available = 3
|
9 |
+
|
10 |
+
|
11 |
+
class spaceManager:
|
12 |
+
def __init__(self):
|
13 |
+
self.spaces_unavailable = {}
|
14 |
+
|
15 |
+
def getSpaceState(self, coordinates):
|
16 |
+
if coordinates in self.spaces_unavailable:
|
17 |
+
return self.spaces_unavailable[coordinates]
|
18 |
+
return space_state.default_available
|
19 |
+
|
20 |
+
def changeSpaceState(self, coordinates, state):
|
21 |
+
if coordinates in self.spaces_unavailable:
|
22 |
+
if self.spaces_unavailable[coordinates].value > state.value:
|
23 |
+
self.spaces_unavailable[coordinates] = state
|
24 |
+
else:
|
25 |
+
self.spaces_unavailable[coordinates] = state
|
26 |
+
|
27 |
+
def getPlacementDetails(self, coordinates, pos, amplitude_dict):
|
28 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
29 |
+
pos1 = pos
|
30 |
+
while self.getSpaceState((x, y, z + pos)) == space_state.unavailable:
|
31 |
+
pos += 1
|
32 |
+
pos2 = pos
|
33 |
+
|
34 |
+
pos = pos1
|
35 |
+
while self.getSpaceState((x, y, z + pos)) == space_state.unavailable:
|
36 |
+
pos -= 1
|
37 |
+
pos0 = pos
|
38 |
+
if (pos0 != 1) and (
|
39 |
+
(pos2 == 49)
|
40 |
+
or (
|
41 |
+
AsfPosConverter.getAmplitude(amplitude_dict, pos0)
|
42 |
+
- AsfPosConverter.getAmplitude(amplitude_dict, pos2)
|
43 |
+
< 2 * AsfPosConverter.getAmplitude(amplitude_dict, pos1)
|
44 |
+
)
|
45 |
+
):
|
46 |
+
pos = pos0
|
47 |
+
else:
|
48 |
+
pos = pos2
|
49 |
+
if (
|
50 |
+
self.getSpaceState((x, y, z + pos))
|
51 |
+
== space_state.available_without_connector
|
52 |
+
):
|
53 |
+
return pos, False
|
54 |
+
elif self.getSpaceState((x, y, z + pos)) == space_state.default_available:
|
55 |
+
return pos, True
|
56 |
+
|
57 |
+
def savePlacementDetails(self, coordinates, state):
|
58 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
59 |
+
if state == "instant_repeater":
|
60 |
+
self.changeSpaceState((x, y, z), space_state.available_without_connector)
|
61 |
+
self.changeSpaceState((x, y, z + 1), space_state.unavailable)
|
62 |
+
self.changeSpaceState((x, y, z + 2), space_state.unavailable)
|
63 |
+
self.changeSpaceState(
|
64 |
+
(x, y, z + 3), space_state.available_without_connector
|
65 |
+
)
|
66 |
+
else:
|
67 |
+
if state == "note_block_with_connector":
|
68 |
+
self.changeSpaceState((x, y, z), space_state.unavailable)
|
69 |
+
self.changeSpaceState(
|
70 |
+
(x, y, z - 1), space_state.available_without_connector
|
71 |
+
)
|
72 |
+
self.changeSpaceState(
|
73 |
+
(x, y, z + 1), space_state.available_without_connector
|
74 |
+
)
|
75 |
+
elif state == "note_block_without_connector":
|
76 |
+
self.changeSpaceState((x, y, z), space_state.unavailable)
|
77 |
+
|
78 |
+
|
79 |
+
class commandGenerator:
|
80 |
+
@staticmethod
|
81 |
+
def getCleanSpace(coordinates, l, b, h):
|
82 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
83 |
+
res = f"fill {x} {y} {z} {x + l} {y + b} {z + h} air\n"
|
84 |
+
return res
|
85 |
+
|
86 |
+
@staticmethod
|
87 |
+
def getInstantRepeater(coordinates):
|
88 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
89 |
+
res = f"""
|
90 |
+
#---------INSTANT_REPEATER-----------
|
91 |
+
setblock {x} {y} {z} redstone_lamp
|
92 |
+
setblock {x} {y + 1} {z} sticky_piston[facing=south]
|
93 |
+
setblock {x} {y + 1} {z + 1} redstone_block
|
94 |
+
setblock {x} {y} {z + 2} sticky_piston[facing=north,extended=true]
|
95 |
+
setblock {x} {y} {z + 3} redstone_lamp
|
96 |
+
setblock {x} {y + 1} {z + 3} redstone_wire
|
97 |
+
#------------------------------------
|
98 |
+
"""
|
99 |
+
return res
|
100 |
+
|
101 |
+
@staticmethod
|
102 |
+
def getNoteBlock(coordinates, inc, block, pos, place_connector):
|
103 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
104 |
+
res = ""
|
105 |
+
if place_connector:
|
106 |
+
res += f"""
|
107 |
+
#--------------NOTE_BLOCK-{pos}-------------------
|
108 |
+
setblock {x} {y-1} {z + pos} glass
|
109 |
+
setblock {x} {y} {z + pos} redstone_wire"""
|
110 |
+
else:
|
111 |
+
res += f"""
|
112 |
+
#--------------NOTE_BLOCK-{pos}-------------------"""
|
113 |
+
res += f"""
|
114 |
+
setblock {x + inc} {y - 2} {z + pos} glass
|
115 |
+
setblock {x + inc} {y - 1} {z + pos} {block['block_name']}
|
116 |
+
setblock {x + inc} {y} {z + pos} note_block[note={block['note']}]
|
117 |
+
#-----------------------------------------------
|
118 |
+
"""
|
119 |
+
return res
|
120 |
+
|
121 |
+
@staticmethod
|
122 |
+
def getMainRepeaterAndRedstoneLine(coordinates, tm, inc):
|
123 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
124 |
+
dir = "west" if inc == 1 else "east"
|
125 |
+
res = f"""
|
126 |
+
#------------------------------------{tm / 1000}-----------------------------------------
|
127 |
+
setblock {x} {y - 1} {z} glass
|
128 |
+
setblock {x} {y} {z} repeater[delay=1,facing={dir}]
|
129 |
+
|
130 |
+
fill {x + inc} {y - 1} {z} {x + inc} {y - 1} {z + 48} glass
|
131 |
+
fill {x + inc} {y} {z} {x + inc} {y} {z + 48} redstone_wire
|
132 |
+
|
133 |
+
setblock {x + 2*inc} {y - 1} {z} glass
|
134 |
+
setblock {x + 2*inc} {y} {z} redstone_wire
|
135 |
+
"""
|
136 |
+
return res
|
137 |
+
|
138 |
+
@staticmethod
|
139 |
+
def getUpperFloorConnection(coordinates, inc):
|
140 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
141 |
+
res = f"""
|
142 |
+
#--------------UPPER-FLOOR-CONNECTION-------------------
|
143 |
+
setblock {x} {y-1} {z} glass
|
144 |
+
setblock {x} {y} {z} redstone_wire
|
145 |
+
setblock {x + inc} {y - 1} {z} glass
|
146 |
+
setblock {x + inc} {y} {z} redstone_wire
|
147 |
+
setblock {x + inc} {y} {z - 1} glass
|
148 |
+
setblock {x + inc} {y + 1} {z - 1} redstone_wire
|
149 |
+
setblock {x + inc} {y + 1} {z - 2} glass
|
150 |
+
setblock {x + inc} {y + 2} {z - 2} redstone_wire
|
151 |
+
setblock {x + 2 * inc} {y + 2} {z - 2} glass
|
152 |
+
setblock {x + 2 * inc} {y + 3} {z - 2} redstone_wire
|
153 |
+
setblock {x + 2 * inc} {y + 3} {z - 1} glass
|
154 |
+
setblock {x + 2 * inc} {y + 4} {z - 1} redstone_wire
|
155 |
+
setblock {x + 2 * inc} {y + 3} {z} glass
|
156 |
+
setblock {x + 2 * inc} {y + 4} {z} redstone_wire
|
157 |
+
#-------------------------------------------------------
|
158 |
+
"""
|
159 |
+
return res
|
160 |
+
|
161 |
+
@staticmethod
|
162 |
+
def getMineCartRailsStarter(coordinates):
|
163 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
164 |
+
res = f"""
|
165 |
+
#--------------MINECART-RAIL-STARTER-------------------
|
166 |
+
setblock {x - 1} {y} {z} redstone_wire
|
167 |
+
setblock {x - 2} {y} {z} redstone_wire
|
168 |
+
setblock {x - 2} {y} {z - 1} redstone_wire
|
169 |
+
setblock {x - 2} {y} {z - 2} redstone_wire
|
170 |
+
setblock {x - 2} {y} {z - 3} redstone_wire
|
171 |
+
setblock {x - 2} {y} {z - 4} redstone_wire
|
172 |
+
setblock {x - 1} {y} {z - 4} redstone_wire
|
173 |
+
setblock {x} {y} {z-4} redstone_wire
|
174 |
+
setblock {x + 1} {y} {z - 4} redstone_wire
|
175 |
+
setblock {x + 2} {y} {z - 4} repeater[delay=1,facing=east]
|
176 |
+
setblock {x + 3} {y} {z - 4} redstone_wire
|
177 |
+
setblock {x + 4} {y} {z - 4} redstone_wire
|
178 |
+
setblock {x + 5} {y} {z - 4} redstone_wire
|
179 |
+
setblock {x + 6} {y} {z - 4} redstone_wire
|
180 |
+
setblock {x + 7} {y} {z - 4} redstone_wire
|
181 |
+
setblock {x + 8} {y} {z - 4} redstone_wire
|
182 |
+
setblock {x + 9} {y} {z - 4} redstone_wire
|
183 |
+
setblock {x + 10} {y} {z - 4} redstone_wire
|
184 |
+
setblock {x + 11} {y} {z - 4} redstone_wire
|
185 |
+
setblock {x + 12} {y} {z - 4} repeater[delay=1,facing=east]
|
186 |
+
setblock {x + 13} {y} {z - 4} redstone_wire
|
187 |
+
setblock {x + 14} {y} {z - 4} redstone_wire
|
188 |
+
setblock {x + 15} {y} {z - 4} redstone_wire
|
189 |
+
setblock {x + 16} {y} {z - 4} redstone_wire
|
190 |
+
setblock {x + 17} {y} {z - 4} redstone_wire
|
191 |
+
setblock {x + 18} {y} {z - 4} redstone_wire
|
192 |
+
setblock {x + 19} {y} {z - 4} stone_button[face=floor]
|
193 |
+
setblock {x + 19} {y} {z - 3} redstone_wire
|
194 |
+
setblock {x + 19} {y} {z - 2} smooth_quartz
|
195 |
+
setblock {x + 20} {y} {z - 2} powered_rail
|
196 |
+
summon minecart {x + 20} {y} {z - 2}
|
197 |
+
setblock {x + 21} {y} {z - 2} rail
|
198 |
+
setblock {x + 22} {y} {z - 2} powered_rail
|
199 |
+
#-------------------------------------------------------
|
200 |
+
"""
|
201 |
+
return res
|
202 |
+
|
203 |
+
@staticmethod
|
204 |
+
def getMineCartRailsEnder(coordinates, inc):
|
205 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
206 |
+
|
207 |
+
if inc == 1:
|
208 |
+
x = x + 23
|
209 |
+
z = z - 2
|
210 |
+
else:
|
211 |
+
x = x - 26
|
212 |
+
z = z - 1
|
213 |
+
|
214 |
+
res = f"""
|
215 |
+
#--------------MINECART-RAIL-ENDER-------------------
|
216 |
+
setblock {x} {y - 1} {z - 1} smooth_quartz
|
217 |
+
setblock {x} {y} {z - 1} redstone_torch
|
218 |
+
setblock {x} {y - 1} {z} smooth_quartz
|
219 |
+
setblock {x} {y} {z} powered_rail
|
220 |
+
setblock {x + inc} {y - 1} {z} smooth_quartz
|
221 |
+
setblock {x + inc} {y} {z} rail
|
222 |
+
setblock {x + 2 * inc} {y - 1} {z} smooth_quartz
|
223 |
+
setblock {x + 2 * inc} {y} {z} powered_rail
|
224 |
+
summon minecart {x + 2 * inc} {y} {z}
|
225 |
+
setblock {x + 3 * inc} {y - 1} {z} smooth_quartz
|
226 |
+
setblock {x + 3 * inc} {y} {z} smooth_quartz
|
227 |
+
#-------------------------------------------------------
|
228 |
+
"""
|
229 |
+
return res
|
230 |
+
|
231 |
+
@staticmethod
|
232 |
+
def getMineCartRails(coordinates, inc):
|
233 |
+
x, y, z = coordinates[0], coordinates[1], coordinates[2]
|
234 |
+
|
235 |
+
if inc == 1:
|
236 |
+
x = x + 23
|
237 |
+
z = z - 2
|
238 |
+
else:
|
239 |
+
x = x - 26
|
240 |
+
z = z - 1
|
241 |
+
|
242 |
+
res = f"""
|
243 |
+
#--------------MINECART-RAIL-SUPPORT-------------------
|
244 |
+
setblock {x} {y - 1} {z - 1} smooth_quartz
|
245 |
+
setblock {x} {y} {z - 1} redstone_torch
|
246 |
+
setblock {x} {y - 1} {z} smooth_quartz
|
247 |
+
setblock {x} {y} {z} powered_rail
|
248 |
+
setblock {x + inc} {y} {z} smooth_quartz
|
249 |
+
setblock {x + inc} {y + 1} {z} powered_rail
|
250 |
+
setblock {x + 2 * inc} {y + 1} {z} smooth_quartz
|
251 |
+
setblock {x + 2 * inc} {y + 2} {z} powered_rail
|
252 |
+
setblock {x + 3 * inc} {y + 2} {z} smooth_quartz
|
253 |
+
setblock {x + 3 * inc} {y + 3} {z} powered_rail
|
254 |
+
setblock {x + 4 * inc} {y + 2} {z} smooth_quartz
|
255 |
+
setblock {x + 4 * inc} {y + 3} {z} powered_rail
|
256 |
+
setblock {x + 5 * inc} {y + 2} {z} smooth_quartz
|
257 |
+
setblock {x + 5 * inc} {y + 3} {z} powered_rail
|
258 |
+
setblock {x + 6 * inc} {y + 2} {z} smooth_quartz"""
|
259 |
+
|
260 |
+
if inc == 1:
|
261 |
+
res += f"""
|
262 |
+
setblock {x + 6 * inc} {y + 3} {z} rail
|
263 |
+
setblock {x + 6 * inc} {y + 2} {z + inc} smooth_quartz
|
264 |
+
setblock {x + 6 * inc} {y + 3} {z + inc} rail"""
|
265 |
+
else:
|
266 |
+
res += f"""
|
267 |
+
setblock {x + 6 * inc} {y + 3} {z} powered_rail
|
268 |
+
setblock {x + 7 * inc} {y + 2} {z} smooth_quartz
|
269 |
+
setblock {x + 7 * inc} {y + 3} {z} rail
|
270 |
+
setblock {x + 7 * inc} {y + 2} {z + inc} smooth_quartz
|
271 |
+
setblock {x + 7 * inc} {y + 3} {z + inc} rail
|
272 |
+
setblock {x + 6 * inc} {y + 2} {z + inc} smooth_quartz
|
273 |
+
setblock {x + 6 * inc} {y + 3} {z + inc} powered_rail"""
|
274 |
+
|
275 |
+
res += f"""
|
276 |
+
setblock {x + 5 * inc} {y + 2} {z + inc} smooth_quartz
|
277 |
+
setblock {x + 5 * inc} {y + 3} {z + inc} powered_rail
|
278 |
+
setblock {x + 4 * inc} {y + 3} {z + inc} smooth_quartz
|
279 |
+
setblock {x + 4 * inc} {y + 4} {z + inc} powered_rail
|
280 |
+
setblock {x + 3 * inc} {y + 3} {z + inc} smooth_quartz
|
281 |
+
setblock {x + 3 * inc} {y + 4} {z + inc} powered_rail
|
282 |
+
setblock {x + 2 * inc} {y + 3} {z + inc} smooth_quartz
|
283 |
+
setblock {x + 2 * inc} {y + 4} {z + inc} powered_rail
|
284 |
+
setblock {x + 1 * inc} {y + 3} {z + inc} smooth_quartz
|
285 |
+
setblock {x + 1 * inc} {y + 4} {z + inc} powered_rail
|
286 |
+
#-------------------------------------------------------
|
287 |
+
"""
|
288 |
+
return res
|
289 |
+
|
290 |
+
|
291 |
+
if __name__ == "__main__":
|
292 |
+
print(
|
293 |
+
"This is a library for Audio Manipulation via fourier transform made specificaly for minecraft audio production using note blocks"
|
294 |
+
)
|
295 |
+
print("Author -: Rajat Bansal, IIT Mandi, B20123")
|
296 |
+
print("Sample Command -:")
|
297 |
+
print(commandGenerator.getCleanSpace((0, 0, 0), 1, 1, 1))
|
MusicAnalyzer/RajatsMinecraftLibrary/test.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from rajatsLibrary.audio import AudioManipulator
|
2 |
+
# import librosa
|
3 |
+
# import matplotlib.pyplot as plt
|
4 |
+
# import numpy as np
|
5 |
+
|
6 |
+
|
7 |
+
# testAudio, _ = librosa.load('Base sounds correct.m4a')
|
8 |
+
# print(len(testAudio))
|
9 |
+
# # testAudio = testAudio[:6000]
|
10 |
+
# # audios = []
|
11 |
+
# # for i in range(24):
|
12 |
+
# # audios.extend(AudioManipulator.shiftPitchOfAudioValues(testAudio, _, i))
|
13 |
+
# # cleanAudio = []
|
14 |
+
# # noiceOnce = testAudio[:20000]
|
15 |
+
# # mxNoice = max(abs(noiceOnce))
|
16 |
+
|
17 |
+
# # for audioPoint in testAudio:
|
18 |
+
# # if(abs(audioPoint) > mxNoice):
|
19 |
+
# # cleanAudio.append(audioPoint)
|
20 |
+
# # else:
|
21 |
+
# # cleanAudio.append(0)
|
22 |
+
|
23 |
+
# # cleanAudio = cleanAudio[20000:]
|
24 |
+
# # cleanAudio = cleanAudio[:-20000]
|
25 |
+
|
26 |
+
# # noice = []
|
27 |
+
# # while len(noice) < len(testAudio):
|
28 |
+
# # noice.extend(noiceOnce)
|
29 |
+
# # print(len(noice))
|
30 |
+
|
31 |
+
# # testAudio = testAudio - noice[:len(testAudio)]
|
32 |
+
# plt.plot(testAudio)
|
33 |
+
# # plt.xticks(np.arange(0, len(testAudio)+1, 16000.0))
|
34 |
+
# plt.grid()
|
35 |
+
# plt.show()
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
# import os
|
41 |
+
# import librosa
|
42 |
+
# import matplotlib.pyplot as plt
|
43 |
+
|
44 |
+
|
45 |
+
# audios = []
|
46 |
+
# instruments = os.listdir('Instruments copy')
|
47 |
+
# instruments = sorted(instruments)
|
48 |
+
# instruments1 = instruments[:7]
|
49 |
+
# instruments2 = instruments[7:]
|
50 |
+
# instruments2.extend(instruments1)
|
51 |
+
# instruments = instruments2
|
52 |
+
# print(instruments)
|
53 |
+
# scaling_factors = [0.92, 1.94, 3.16, 1.41, 0.633, 0.775, 3.954, 1.712, 0.861, 1.327, 3.768, 1.013, 2.307, 0.645, 10.482, 1.255]
|
54 |
+
# i = 0
|
55 |
+
# for instrument in instruments:
|
56 |
+
# audioValues, _ = librosa.load('Instruments copy/' + instrument)
|
57 |
+
# audioValues = audioValues * scaling_factors[i]
|
58 |
+
# audios.extend(audioValues)
|
59 |
+
# audios.extend([0] * 10000)
|
60 |
+
# i+=1
|
61 |
+
|
62 |
+
# plt.plot(audios)
|
63 |
+
# plt.grid()
|
64 |
+
# plt.show()
|