Skip to content

Commit 05e0a1b

Browse files
committed
Add tutorial steps
1 parent 32d360c commit 05e0a1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+5067
-0
lines changed

python-guitar-synthesizer/source_code_step_1/README.md

Whitespace-only changes.

python-guitar-synthesizer/source_code_step_1/poetry.lock

Lines changed: 315 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tool.poetry]
2+
name = "digitar"
3+
version = "0.1.0"
4+
description = ""
5+
authors = ["Bartosz Zaczyński <[email protected]>"]
6+
readme = "README.md"
7+
packages = [{include = "digitar", from = "src"}]
8+
9+
[tool.poetry.dependencies]
10+
python = "^3.12"
11+
numpy = "^1.26.4"
12+
pedalboard = "^0.9.6"
13+
pydantic = "^2.7.3"
14+
pyyaml = "^6.0.1"
15+
16+
17+
[build-system]
18+
requires = ["poetry-core"]
19+
build-backend = "poetry.core.masonry.api"

python-guitar-synthesizer/source_code_step_1/src/digitar/__init__.py

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from dataclasses import dataclass
2+
from decimal import Decimal
3+
from fractions import Fraction
4+
from typing import Self
5+
6+
type Numeric = int | float | Decimal | Fraction
7+
type Hertz = int | float
8+
9+
10+
@dataclass(frozen=True)
11+
class Time:
12+
seconds: Decimal
13+
14+
@classmethod
15+
def from_milliseconds(cls, milliseconds: Numeric) -> Self:
16+
return cls(Decimal(str(float(milliseconds))) / 1000)
17+
18+
def __init__(self, seconds: Numeric) -> None:
19+
match seconds:
20+
case int() | float():
21+
object.__setattr__(self, "seconds", Decimal(str(seconds)))
22+
case Decimal():
23+
object.__setattr__(self, "seconds", seconds)
24+
case Fraction():
25+
object.__setattr__(
26+
self, "seconds", Decimal(str(float(seconds)))
27+
)
28+
case _:
29+
raise TypeError(f"unsupported type '{type(seconds).__name__}'")
30+
31+
def get_num_samples(self, sampling_rate: Hertz) -> int:
32+
return round(self.seconds * round(sampling_rate))

python-guitar-synthesizer/source_code_step_1/tests/__init__.py

Whitespace-only changes.

python-guitar-synthesizer/source_code_step_2/README.md

Whitespace-only changes.

python-guitar-synthesizer/source_code_step_2/poetry.lock

Lines changed: 315 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tool.poetry]
2+
name = "digitar"
3+
version = "0.1.0"
4+
description = ""
5+
authors = ["Bartosz Zaczyński <[email protected]>"]
6+
readme = "README.md"
7+
packages = [{include = "digitar", from = "src"}]
8+
9+
[tool.poetry.dependencies]
10+
python = "^3.12"
11+
numpy = "^1.26.4"
12+
pedalboard = "^0.9.6"
13+
pydantic = "^2.7.3"
14+
pyyaml = "^6.0.1"
15+
16+
17+
[build-system]
18+
requires = ["poetry-core"]
19+
build-backend = "poetry.core.masonry.api"

python-guitar-synthesizer/source_code_step_2/src/digitar/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)