|
@@ -34,6 +34,7 @@ public class BassMusicPlay {
|
|
|
|
|
|
public boolean Load(Context context, String pathMusic) {
|
|
|
// setup recording device (using default device)
|
|
|
+ Stop();//先释放资源
|
|
|
if (mFmlHandler == null)
|
|
|
mFmlHandler = new FmlHandler(context.getMainLooper());
|
|
|
if (mSingleExecutor == null)
|
|
@@ -163,13 +164,14 @@ public class BassMusicPlay {
|
|
|
public boolean IsStop() {
|
|
|
return (BASS.BASS_ChannelIsActive(midi) == BASS.BASS_ACTIVE_STOPPED);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
* @param speed 1表示原速
|
|
|
*/
|
|
|
- public void setSpeed(float speed){
|
|
|
+ public void setSpeed(float speed) {
|
|
|
BASS.BASS_ChannelSetAttribute(midi, BASSMIDI.BASS_ATTRIB_MIDI_SPEED, speed);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 播放
|
|
|
*/
|
|
@@ -186,21 +188,24 @@ public class BassMusicPlay {
|
|
|
* 由于音源sf2为440基准
|
|
|
* 如果大于440,则为正数
|
|
|
* 如果小于440,为复数
|
|
|
+ *
|
|
|
* @param targetHz 415 ~ 466
|
|
|
* @return
|
|
|
*/
|
|
|
- private int calculateFineTune(int targetHz){
|
|
|
- return (int) ((Math.log((double)targetHz / 440d) * 3986 +100) * 8192 / 100);
|
|
|
+ private int calculateFineTune(int targetHz) {
|
|
|
+ return (int) ((Math.log((double) targetHz / 440d) * 3986 + 100) * 8192 / 100);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置音分偏移
|
|
|
+ *
|
|
|
* @param trackNum
|
|
|
* @param targetHz
|
|
|
*/
|
|
|
- public boolean setNoteFineTune(int trackNum, int targetHz){
|
|
|
+ public boolean setNoteFineTune(int trackNum, int targetHz) {
|
|
|
return BASSMIDI.BASS_MIDI_StreamEvent(midi, trackNum, BASSMIDI.MIDI_EVENT_FINETUNE, BASS.Utils.LOWORD(calculateFineTune(targetHz)));
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 暂停
|
|
|
*/
|
|
@@ -245,9 +250,10 @@ public class BassMusicPlay {
|
|
|
|
|
|
/**
|
|
|
* 获取总的TICK
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- public int GetTotalTICK(){
|
|
|
+ public int GetTotalTICK() {
|
|
|
return (int) BASS.BASS_ChannelGetLength(midi, BASSMIDI.BASS_POS_MIDI_TICK);
|
|
|
}
|
|
|
|
|
@@ -261,8 +267,8 @@ public class BassMusicPlay {
|
|
|
return BASS.BASS_ChannelGetLength(midi, BASS.BASS_POS_BYTE);
|
|
|
}
|
|
|
|
|
|
- public double getTotalLength2Second(){
|
|
|
- return BASS.BASS_ChannelBytes2Seconds(midi, BASS.BASS_ChannelGetLength(midi, BASS.BASS_POS_BYTE));
|
|
|
+ public double getTotalLength2Second() {
|
|
|
+ return BASS.BASS_ChannelBytes2Seconds(midi, BASS.BASS_ChannelGetLength(midi, BASS.BASS_POS_BYTE));
|
|
|
}
|
|
|
|
|
|
/**
|