Skip to content

Commit e37549b

Browse files
committed
Add support for locations
1 parent c1b2f66 commit e37549b

File tree

10 files changed

+87
-8
lines changed

10 files changed

+87
-8
lines changed

blobopera/command/common.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,31 @@ class FillPhoneme(str, Enum):
8383

8484
class InterfaceTheme(str, Enum):
8585
NORMAL = "NORMAL"
86-
FESTIVE = "FESTIVE"
86+
CHRISTMAS = "CHRISTMAS"
87+
NEWYEARS = "NEWYEARS"
8788

8889

8990
DefaultInterfaceTheme = typer.Option(
9091
InterfaceTheme.NORMAL, case_sensitive=False
9192
)
9293

9394

95+
class InterfaceLocation(str, Enum):
96+
BLOBPERAHOUSE = "BLOBPERAHOUSE"
97+
LONDON = "LONDON"
98+
NEWYORK = "NEWYORK"
99+
HACKNEY = "HACKNEY"
100+
PARIS = "PARIS"
101+
CAPETOWN = "CAPETOWN"
102+
MEXICOCITY = "MEXICOCITY"
103+
SEOUL = "SEOUL"
104+
105+
106+
DefaultInterfaceLocation = typer.Option(
107+
InterfaceLocation.BLOBPERAHOUSE, case_sensitive=False
108+
)
109+
110+
94111
def parse(data: bytes, message: Type[Message]) -> Message:
95112
"""Parse a Protocol Buffer message from any of its representations.
96113

blobopera/command/recording.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import typer
77

88
from ..languages import GenericLanguage, RandomLanguage
9+
from ..location import Location
910
from ..phoneme import Phoneme
1011
from ..recording import Recording
1112
from ..theme import Theme
@@ -87,6 +88,7 @@ def _import( # Prepend an underscore because import is a reserved keyword.
8788
theme: common.InterfaceTheme = common.DefaultInterfaceTheme,
8889
language: common.PhonemeLanguage = common.DefaultPhonemeLanguage,
8990
fill: common.FillPhoneme = common.DefaultFillPhoneme,
91+
location: common.InterfaceLocation = common.DefaultInterfaceLocation,
9092
soprano_part: int = 0,
9193
alto_part: int = 1,
9294
tenor_part: int = -2,
@@ -121,6 +123,9 @@ def _import( # Prepend an underscore because import is a reserved keyword.
121123
Tempo: this value modifies the global tempo by the specified amount;
122124
0.5 would slow down the piece to half its original speed, and 2.0
123125
would make it twice as quicker.
126+
127+
Location: the location (i.e. background image) of the recording, like
128+
e.g. Seoul or London.
124129
"""
125130

126131
if language == common.PhonemeLanguage.GENERIC:
@@ -144,6 +149,7 @@ def _import( # Prepend an underscore because import is a reserved keyword.
144149
tempo=tempo,
145150
parts=parts,
146151
fill=Phoneme[fill.value],
152+
location=Location[location.value]
147153
)
148154

149155
output.write(

blobopera/location.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Graphical user interface locations.
2+
3+
This module describes the location pictures that can be used in
4+
the Blob Opera application user interface.
5+
"""
6+
import proto # type: ignore
7+
8+
__protobuf__ = proto.module(package=__name__)
9+
10+
11+
class Location(proto.Enum):
12+
"""Background picture for the Blob Opera stage.
13+
14+
Note:
15+
BlobperaHouse is a generic background.
16+
Others are blurry outdoor views of emblematic places.
17+
"""
18+
19+
BLOBPERAHOUSE = 0
20+
LONDON = 1
21+
NEWYORK = 2
22+
HACKNEY = 3
23+
PARIS = 4
24+
CAPETOWN = 5
25+
MEXICOCITY = 6
26+
SEOUL = 7

blobopera/recording.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from more_itertools import split_before, windowed_complete
77

88
from .languages import GenericLanguage, Language
9+
from .location import Location
910
from .phoneme import Phoneme
1011
from .theme import Theme
1112

@@ -413,6 +414,7 @@ class Recording(proto.Message):
413414

414415
theme = proto.Field(Theme, number=1, optional=True)
415416
parts = proto.RepeatedField(Part, number=2, optional=True)
417+
location = proto.Field(Location, number=3, optional=True)
416418

417419
@classmethod
418420
def from_score(
@@ -423,6 +425,7 @@ def from_score(
423425
tempo: float = 1.0,
424426
parts: Tuple[int] = (0, 0, 0, 0),
425427
fill: Phoneme = Phoneme.SILENCE,
428+
location: Location = Location.BLOBPERAHOUSE,
426429
):
427430
"""Create a Blob Opera recording from a music21 score.
428431
@@ -454,7 +457,7 @@ def from_score(
454457
if len(parts) != 4:
455458
raise ValueError("recordings require exactly four tracks")
456459
try:
457-
recording = Recording(theme=theme)
460+
recording = Recording(theme=theme, location=location)
458461
for index in parts:
459462
part = Part.from_part(
460463
score.parts[index],

blobopera/theme.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ class Theme(proto.Enum):
1212
"""Graphical user interface theme.
1313
1414
Note:
15-
The :py:attr:`FESTIVE` theme adds lots of tiny falling snowflakes
15+
The :py:attr:`CHRISTMAS` theme adds lots of tiny falling snowflakes
1616
in the background and Santa Claus hats over the singers.
17+
18+
The :py:attr:`NEWYEARS` theme adds lots of tiny falling snowflakes
19+
in the background, party hats over the singers and a big aluminum
20+
balloon with the year on it hovering their heads.
1721
"""
1822

1923
NORMAL = 0
20-
FESTIVE = 1
24+
CHRISTMAS = 1
25+
NEWYEARS = 2

documentation/command/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ Options:
302302
0.5 would slow down the piece to half its original speed, and 2.0
303303
would make it twice as quicker.
304304

305+
Location: the location (i.e. background image) of the recording, like
306+
e.g. Seoul or London.
307+
305308
**Usage**:
306309

307310
```console
@@ -316,9 +319,10 @@ $ blobopera recording import [OPTIONS] INPUT OUTPUT
316319
**Options**:
317320

318321
* `--format [BINARY|JSON]`: [default: BINARY]
319-
* `--theme [NORMAL|FESTIVE]`: [default: NORMAL]
322+
* `--theme [NORMAL|CHRISTMAS|NEWYEARS]`: [default: NORMAL]
320323
* `--language [GENERIC|RANDOM]`: [default: GENERIC]
321-
* `--fill [SILENCE|A|E|I|O|U]`: [default: SILENCE]
324+
* `--fill [SILENCE|A|E|I|O|U]`: [default: U]
325+
* `--location [BLOBPERAHOUSE|LONDON|NEWYORK|HACKNEY|PARIS|CAPETOWN|MEXICOCITY|SEOUL]`: [default: BLOBPERAHOUSE]
322326
* `--soprano-part INTEGER`: [default: 0]
323327
* `--alto-part INTEGER`: [default: 1]
324328
* `--tenor-part INTEGER`: [default: -2]

documentation/protocol/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ purposes.
2525
* **`Theme`** contains a list of valid themes; the festive theme adds
2626
falling snow and a red fluffy hat for each blob.
2727

28+
* **`Location`** contains a list of valid locations; i.e. blurry background
29+
pictures of emblematic places.
30+
2831
## Usage
2932

3033
```bash
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
syntax = "proto2";
2+
3+
enum Location {
4+
BlobperaHouse = 0;
5+
London = 1;
6+
NewYork = 2;
7+
Hackney = 3;
8+
Paris = 4;
9+
CapeTown = 5;
10+
MexicoCity = 6;
11+
Seoul = 7;
12+
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
syntax = "proto2";
22

33
enum Theme {
4-
Normal = 0;
5-
Festive = 1;
4+
Normal = 0;
5+
Christmas = 1;
6+
NewYears = 2;
67
}

documentation/protocol/messages/recording.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto2";
22

3+
import "enumerations/location.proto";
34
import "enumerations/phoneme.proto";
45
import "enumerations/theme.proto";
56

@@ -28,4 +29,5 @@ message RecordingMessage {
2829

2930
required Theme theme = 1;
3031
repeated Part parts = 2;
32+
required Location location = 3;
3133
}

0 commit comments

Comments
 (0)