|
@@ -32,6 +32,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|
public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBinding> implements View.OnClickListener, VolumeManager.VolumeChangeListener {
|
|
public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBinding> implements View.OnClickListener, VolumeManager.VolumeChangeListener {
|
|
public MetronomeType currentBeatType;
|
|
public MetronomeType currentBeatType;
|
|
public int currentBeatRate = MetronomeConfig.DEFAULT_PLAY_RATE;
|
|
public int currentBeatRate = MetronomeConfig.DEFAULT_PLAY_RATE;
|
|
|
|
+ public float currentNoteRate = MetronomeConfig.DEFAULT_NOTE_RATE;
|
|
private SoundPool soundPool;
|
|
private SoundPool soundPool;
|
|
private int tickVoiceId;
|
|
private int tickVoiceId;
|
|
private int tockVoiceId;
|
|
private int tockVoiceId;
|
|
@@ -42,7 +43,7 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
private Runnable mRunnable = new Runnable() {
|
|
private Runnable mRunnable = new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
- long delayMillis = (long) (1 / (currentBeatRate / 60d) * 1000);
|
|
|
|
|
|
+ long delayMillis = (long) (1 / (currentBeatRate / 60d) * 1000 * currentNoteRate);
|
|
boolean tickOrTock = isTickOrTock();
|
|
boolean tickOrTock = isTickOrTock();
|
|
if (tickOrTock) {
|
|
if (tickOrTock) {
|
|
soundPool.play(tickVoiceId, 1F, 1F, 0, 0, 1F);
|
|
soundPool.play(tickVoiceId, 1F, 1F, 0, 0, 1F);
|
|
@@ -81,7 +82,7 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void initView() {
|
|
protected void initView() {
|
|
- initMidTitleToolBar(viewBinding.toolbarInclude.toolbar,"节拍器");
|
|
|
|
|
|
+ initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "节拍器");
|
|
viewBinding.toolbarInclude.toolbar.setBackgroundColor(Color.TRANSPARENT);
|
|
viewBinding.toolbarInclude.toolbar.setBackgroundColor(Color.TRANSPARENT);
|
|
updateSpeedText();
|
|
updateSpeedText();
|
|
}
|
|
}
|
|
@@ -102,6 +103,9 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
playPosition = 0;
|
|
playPosition = 0;
|
|
mMetronomeAdapter.notifyData(MetronomeAdapter.DEFAULT_SELECT_POSITION);
|
|
mMetronomeAdapter.notifyData(MetronomeAdapter.DEFAULT_SELECT_POSITION);
|
|
mMetronomeAdapter.setCount(getBeatSymbolCount());
|
|
mMetronomeAdapter.setCount(getBeatSymbolCount());
|
|
|
|
+ currentNoteRate = MetronomeType.getNoteSpeedValue(metronomeType);
|
|
|
|
+ int noteDrawable = MetronomeConfig.getNoteDrawable(metronomeType);
|
|
|
|
+ viewBinding.ivNote.setImageResource(noteDrawable);
|
|
}
|
|
}
|
|
|
|
|
|
private int getBeatSymbolCount() {
|
|
private int getBeatSymbolCount() {
|
|
@@ -128,6 +132,10 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
if (value == MetronomeType.METRONOME_68_TYPE.getValue()) {
|
|
if (value == MetronomeType.METRONOME_68_TYPE.getValue()) {
|
|
return 6;
|
|
return 6;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (value == MetronomeType.METRONOME_816_TYPE.getValue()) {
|
|
|
|
+ return 8;
|
|
|
|
+ }
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -144,13 +152,14 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
mteronomeSoundPool();
|
|
mteronomeSoundPool();
|
|
beatSymbolLists = new ArrayList<>();
|
|
beatSymbolLists = new ArrayList<>();
|
|
beatSymbolLists.add(MetronomeType.METRONOME_12_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_12_TYPE);
|
|
- beatSymbolLists.add(MetronomeType.METRONOME_22_TYPE);
|
|
|
|
beatSymbolLists.add(MetronomeType.METRONOME_14_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_14_TYPE);
|
|
|
|
+ beatSymbolLists.add(MetronomeType.METRONOME_22_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_24_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_24_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_34_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_34_TYPE);
|
|
- beatSymbolLists.add(MetronomeType.METRONOME_44_TYPE);
|
|
|
|
beatSymbolLists.add(MetronomeType.METRONOME_38_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_38_TYPE);
|
|
|
|
+ beatSymbolLists.add(MetronomeType.METRONOME_44_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_68_TYPE);
|
|
beatSymbolLists.add(MetronomeType.METRONOME_68_TYPE);
|
|
|
|
+ beatSymbolLists.add(MetronomeType.METRONOME_816_TYPE);
|
|
mVolumeManager = new VolumeManager(this);
|
|
mVolumeManager = new VolumeManager(this);
|
|
mVolumeManager.setVolumeChangeListener(this);
|
|
mVolumeManager.setVolumeChangeListener(this);
|
|
mVolumeManager.registerReceiver();
|
|
mVolumeManager.registerReceiver();
|
|
@@ -290,6 +299,8 @@ public class MetronomeActivity extends BaseActivity<ActivityMetronomeLayoutBindi
|
|
return true;
|
|
return true;
|
|
} else if (currentBeatType.getValue() == MetronomeType.METRONOME_68_TYPE.getValue() && playPosition % 6 == 0) {
|
|
} else if (currentBeatType.getValue() == MetronomeType.METRONOME_68_TYPE.getValue() && playPosition % 6 == 0) {
|
|
return true;
|
|
return true;
|
|
|
|
+ } else if (currentBeatType.getValue() == MetronomeType.METRONOME_816_TYPE.getValue() && playPosition % 8 == 0) {
|
|
|
|
+ return true;
|
|
} else {
|
|
} else {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|