-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backend module and put all the backend logics there
- Loading branch information
Showing
7 changed files
with
84 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from .utils import ( | ||
list_audio_backends, | ||
get_audio_backend, | ||
set_audio_backend, | ||
) | ||
from .sox_backend import ( | ||
save_encinfo, | ||
sox_signalinfo_t, | ||
sox_encodinginfo_t, | ||
get_sox_option_t, | ||
get_sox_encoding_t, | ||
get_sox_bool, | ||
) | ||
from .common import ( | ||
SignalInfo, | ||
EncodingInfo, | ||
) | ||
|
||
|
||
def _init_backend(): | ||
backends = list_audio_backends() | ||
if 'sox' in backends: | ||
set_audio_backend('sox') | ||
elif 'soundfile' in backends: | ||
set_audio_backend('soundfile') | ||
else: | ||
import warnings | ||
warnings.warn('No audio backend is available.') | ||
|
||
|
||
_init_backend() | ||
del _init_backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Any, Optional | ||
|
||
|
||
class SignalInfo: | ||
def __init__(self, | ||
channels: Optional[int] = None, | ||
rate: Optional[float] = None, | ||
precision: Optional[int] = None, | ||
length: Optional[int] = None) -> None: | ||
self.channels = channels | ||
self.rate = rate | ||
self.precision = precision | ||
self.length = length | ||
|
||
|
||
class EncodingInfo: | ||
def __init__(self, | ||
encoding: Any = None, | ||
bits_per_sample: Optional[int] = None, | ||
compression: Optional[float] = None, | ||
reverse_bytes: Any = None, | ||
reverse_nibbles: Any = None, | ||
reverse_bits: Any = None, | ||
opposite_endian: Optional[bool] = None) -> None: | ||
self.encoding = encoding | ||
self.bits_per_sample = bits_per_sample | ||
self.compression = compression | ||
self.reverse_bytes = reverse_bytes | ||
self.reverse_nibbles = reverse_nibbles | ||
self.reverse_bits = reverse_bits | ||
self.opposite_endian = opposite_endian |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters