Skip to content

Commit

Permalink
plot functionality is improved
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhydri committed Nov 5, 2021
1 parent 2b822ea commit 9d2f0de
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 19 deletions.
19 changes: 19 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed dist/jump_reward_inference-0.0.5-py3-none-any.whl
Binary file not shown.
Binary file removed dist/jump_reward_inference-0.0.5.tar.gz
Binary file not shown.
Binary file added dist/jump_reward_inference-0.0.6-py3-none-any.whl
Binary file not shown.
Binary file added dist/jump_reward_inference-0.0.6.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def run(self):

# Package details
name="jump_reward_inference",
version="0.0.5",
version="0.0.6",
package_dir={"": "src"},
packages=find_packages(where="src"),
# packages=find_packages(),
Expand Down
2 changes: 1 addition & 1 deletion src/jump_reward_inference.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: jump-reward-inference
Version: 0.0.5
Version: 0.0.6
Summary: A package for online music joint rhythmic parameters tracking including beats, downbeats, tempo and meter using the BeatNet AI, a super compact 1D state space and the jump back reward technique
Home-page: https://github.com/mjhydri/1D-StateSpace
Author: Mojtaba Heydari
Expand Down
17 changes: 11 additions & 6 deletions src/jump_reward_inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class BDObservationModel:
beat tracking method using RNN and enhanced particle filtering,” in In Proc. IEEE Int. Conf. Acoust. Speech
Signal Process. (ICASSP), 2021.
M. Heydari, F. Cwitkowitz, and Z. Duan, “BeatNet:CRNN and particle filtering for online joint beat down-beat
and meter tracking,” in Proc. of the 22th Intl. Conf.on Music Information Retrieval (ISMIR), 2021.
M. Heydari and Z. Duan, “Don’t Look Back: An online beat tracking method using RNN and enhanced
particle filtering,” in Proc. IEEE Int. Conf. Acoust. Speech Signal Process. (ICASSP), 2021.
"""

Expand Down Expand Up @@ -132,8 +138,7 @@ class inference_1D:
'''
MIN_BPM = 55.
MAX_BPM = 200. # 215.
NUM_TEMPI = 300
MAX_BPM = 215.
LAMBDA_B = 0.01 # beat transition lambda
Lambda_D = 0.01 # downbeat transition lambda
OBSERVATION_LAMBDA = "B56"
Expand Down Expand Up @@ -169,7 +174,7 @@ def __init__(self, beats_per_bar=[], min_bpm=MIN_BPM, max_bpm=MAX_BPM, offset=OF
self.om2 = BDObservationModel(self.st2, "B60") # downbeat tracking observation model
pass

def process(self, activations, **kwargs):
def process(self, activations):
T = 1 / self.fps
font = {'color': 'green', 'weight': 'normal', 'size': 12}
counter = 0
Expand Down Expand Up @@ -275,14 +280,14 @@ def process(self, activations, **kwargs):
self.st2.jump_weights[:self.st2.min_interval - 1] = 0
down_max = np.argmax(down_distribution)

# Beat vs Downbeat distinguishment
# Beat vs Downbeat mark off
if down_max == self.st2.first_states[0]:
output = np.append(output, [[counter * T + self.offset, 1, local_tempo, meter]], axis=0)
last_detected = "Downbeat"
else:
output = np.append(output, [[counter * T + self.offset, 2, local_tempo, meter]], axis=0)
last_detected = "Beat"
if self.plot and counter>5000: #and counter>5000
if self.plot:
subplot3.cla()
subplot4.cla()
down_distribution = down_distribution / np.max(down_distribution)
Expand All @@ -303,7 +308,7 @@ def process(self, activations, **kwargs):
position2 = down_max
subplot3.axvline(x=position2)

if self.plot and counter>5000: # and counter>5000 # activates this when you want to plot the performance
if self.plot: # activates this when you want to plot the performance
if counter % 1 == 0: # Choosing how often to plot
print(counter)
subplot1.cla()
Expand Down
4 changes: 2 additions & 2 deletions src/jump_reward_inference/state_space_1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class beat_state_space_1D(state_space_1D):

def __init__(self, alpha=0.01, tempo=None, fps=None, min_interval=None, max_interval=None):
super().__init__(min_interval, max_interval)
self.jump_weights = np.concatenate((np.zeros(self.min_interval), np.array([alpha] * (self.max_interval - self.min_interval)), ))
self.jump_weights = np.concatenate((np.zeros(self.min_interval), np.array([alpha] * (self.max_interval - self.min_interval)),))
if tempo and fps:
self.jump_weights[round(60. * fps / tempo) - self.min_interval] = 1 - alpha

Expand All @@ -32,7 +32,7 @@ class downbeat_state_space_1D(state_space_1D):

def __init__(self, alpha=0.1, meter=None, min_beats_per_bar=None, max_beats_per_bar=None):
super().__init__(min_beats_per_bar, max_beats_per_bar)
self.jump_weights = np.concatenate((np.zeros(self.min_interval-1), np.array([alpha] * (self.max_interval - self.min_interval+1)), ))
self.jump_weights = np.concatenate((np.zeros(self.min_interval-1), np.array([alpha] * (self.max_interval - self.min_interval+1)),))
if meter:
self.jump_weights[meter[0] - self.min_interval+1] = 1 - alpha
pass
Expand Down

0 comments on commit 9d2f0de

Please sign in to comment.