-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
182 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
cff-version: 1.2.0 | ||
message: "If you use this software in your work, please cite the SMC 2020 paper as below." | ||
authors: | ||
- family-names: "Tiraboschi" | ||
given-names: "Marco" | ||
orcid: "https://orcid.org/0000-0001-5761-4837" | ||
title: "SAMPLE" | ||
version: 1.5.0a2 | ||
date-released: 2021-02-26 | ||
url: "https://github.com/limunimi/sample" | ||
repository-code: "https://github.com/limunimi/sample" | ||
license: MIT | ||
type: software | ||
preferred-citation: | ||
type: proceedings | ||
title: "Spectral Analysis for Modal Parameters Linear Estimate" | ||
authors: | ||
- family-names: "Tiraboschi" | ||
given-names: "Marco" | ||
orcid: "https://orcid.org/0000-0001-5761-4837" | ||
- family-names: "Avanzini" | ||
given-names: "Federico" | ||
orcid: "https://orcid.org/0000-0002-1257-5878" | ||
- family-names: "Ntalampiras" | ||
given-names: "Stavros" | ||
orcid: "https://orcid.org/0000-0003-3482-9215" | ||
doi: "10.5281/zenodo.3898795" | ||
journal: "Proceedings of the 17th Sound and Music Computing Conference" | ||
month: 6 | ||
year: 2020 | ||
start: 276 | ||
end: 283 |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## v1.5.0a0 | ||
## v1.5.0a2 | ||
This version is still in its alpha phase | ||
|
||
### GUI | ||
|
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ requests | |
ttkthemes | ||
Pillow | ||
pygame | ||
throttle | ||
|
||
# Pylint | ||
pylint | ||
|
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
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,107 @@ | ||
"""SAMPLE class for use in GUI""" | ||
from sample import sample | ||
from sample.sms import mm | ||
import tkinter as tk | ||
import numpy as np | ||
import throttle | ||
from typing import Optional, Tuple | ||
|
||
|
||
class SAMPLE(sample.SAMPLE): | ||
"""SAMPLE model for use in the GUI. For a full list of arguments see | ||
:class:`sample.sample.SAMPLE`""" | ||
class SinusoidalModel(mm.ModalModel): | ||
"""Sinusoidal tracker for use in the GUI. For a full list of | ||
arguments see :class:`sample.sms.mm.ModalModel` | ||
Args: | ||
progressbar (optional): Progressbar widget for visualizing | ||
the peak tracking progress""" | ||
def __init__( | ||
self, | ||
progressbar: Optional[tk.Widget] = None, | ||
fs: int = 44100, | ||
w: Optional[np.ndarray] = None, | ||
n: int = 2048, | ||
h: int = 500, | ||
t: float = -90, | ||
max_n_sines: int = 100, | ||
min_sine_dur: float = 0.04, | ||
freq_dev_offset: float = 20, | ||
freq_dev_slope: float = 0.01, | ||
reverse: bool = False, | ||
sine_tracker_cls: type = mm.ModalTracker, | ||
save_intermediate: bool = False, | ||
frequency_bounds: Tuple[Optional[float], Optional[float]] = (20, 16000), | ||
peak_threshold: float = -90, | ||
merge_strategy: str = "average", | ||
strip_t: Optional[float] = None, | ||
): | ||
self.progressbar = progressbar | ||
super().__init__( | ||
fs=fs, w=w, n=n, h=h, t=t, | ||
max_n_sines=max_n_sines, | ||
min_sine_dur=min_sine_dur, | ||
freq_dev_offset=freq_dev_offset, | ||
freq_dev_slope=freq_dev_slope, | ||
reverse=reverse, | ||
sine_tracker_cls=sine_tracker_cls, | ||
save_intermediate=save_intermediate, | ||
frequency_bounds=frequency_bounds, | ||
peak_threshold=peak_threshold, | ||
merge_strategy=merge_strategy, | ||
strip_t=strip_t, | ||
) | ||
|
||
def fit(self, x: np.ndarray, y=None, **kwargs): | ||
"""Analyze audio data | ||
Args: | ||
x (array): audio input | ||
y (ignored): exists for compatibility | ||
kwargs: Any parameter, overrides initialization | ||
Returns: | ||
SinusoidalModel: self""" | ||
self.set_params(**kwargs) | ||
self.w_ = self.normalized_window | ||
if self.progressbar is not None: | ||
self.progressbar["maximum"] = -1 | ||
self.progressbar.config( | ||
value=0, | ||
maximum=len(list( | ||
self.time_frames(x) | ||
)) | ||
) | ||
s = super().fit(x=x, y=y) | ||
if self.progressbar is not None: | ||
self.progressbar.config(value=1, maximum=1) | ||
return s | ||
|
||
@throttle.wrap(.0125, 1) | ||
def progressbar_update(self, value: Optional[float] = None): | ||
"""Update the progress bar. This function is throttled""" | ||
if value is not None: | ||
self.progressbar.config(value=value) | ||
self.progressbar.update() | ||
|
||
def time_frames(self, x: np.ndarray): | ||
"""Generator of frames for a given input. Also, | ||
updates the progressbar if one has been specified | ||
Args: | ||
x (array): Input | ||
Returns: | ||
generator: Generator of overlapping frames of the padded input""" | ||
it = super().time_frames(x) | ||
if self.progressbar is not None and self.progressbar["maximum"] > 0: | ||
def func(t): | ||
self.progressbar_update(value=t[0]) | ||
return t[-1] | ||
it = map(func, enumerate(it)) | ||
for f in it: | ||
yield f | ||
|
||
def __init__(self, sinusoidal_model=SinusoidalModel(), **kwargs): | ||
super().__init__(sinusoidal_model=sinusoidal_model, **kwargs) |
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
"pygame", | ||
"matplotlib", | ||
"Pillow", | ||
"throttle", | ||
], | ||
"plots": [ | ||
"matplotlib", | ||
|