26 May '13 - 08:53 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 ... 8 9 [10] 11 12 ... 18
  Reply  |  Print  
Author Topic: BASS for Android  (Read 48395 times)
elimmedia
Posts: 11


« Reply #180 on: 11 Jul '12 - 09:50 »
Reply with quoteQuote

I have a question regarding BASS_MIDI.


MIDI_EVENT_TEMPO, which is global event won't be affected if it is set using "BASS_MIDI_StreamEvent" before play.

Any other way to set tempo before play midi?

thank you in advance
« Last Edit: 11 Jul '12 - 09:55 by elimmedia » Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #181 on: 11 Jul '12 - 13:52 »
Reply with quoteQuote

The problem you are encountering there is that the MIDI file may have its own TEMPO events, which will override your tempo setting. The overcome that, you need re-override the file's TEMPO events, which can be done via a BASS_SYNC_MIDI_EVENT sync. Something like this...

BASSMIDI.BASS_MIDI_StreamEvent(handle, 0, BASSMIDI.MIDI_EVENT_TEMPO, yourtempo); // apply your tempo setting
BASS.BASS_ChannelSetSync(handle, BASSMIDI.BASS_SYNC_MIDI_EVENT|BASS.BASS_SYNC_MIXTIME, BASSMIDI.MIDI_EVENT_TEMPO, TempoSync, 0); // and set a sync to override TEMPO events

BASS.SYNCPROC TempoSync=new BASS.SYNCPROC() {
public void SYNCPROC(int handle, int channel, int data, Object user) {
BASSMIDI.BASS_MIDI_StreamEvent(channel, 0, BASSMIDI.MIDI_EVENT_TEMPO, yourtempo); // apply your tempo setting
}
};

Please see the MIDITEST example for a more complete example of adjusting the tempo.
Logged
BassPassion
Posts: 25


« Reply #182 on: 11 Jul '12 - 14:30 »
Reply with quoteQuote

Now that Android supports Intel in the Emulator1, (which is a awesome performance improvement during development) and devices are starting to pop up using Intel chipsets (like Lenovo K8002) are there any plans of compiling an Intel version of Bass for Android?


1http://developer.android.com/tools/devices/emulator.html
2http://www.techradar.com/news/phone-and-communications/mobile-phones/hands-on-lenovo-k800-review-1053719
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #183 on: 11 Jul '12 - 17:34 »
Reply with quoteQuote

There is an x86 Android version of BASS that is currently available separately on request. I guess it will soon have to be added to the main package Smiley
Logged
elimmedia
Posts: 11


« Reply #184 on: 12 Jul '12 - 01:17 »
Reply with quoteQuote

that makes sense!

Thank you Ian!

The problem you are encountering there is that the MIDI file may have its own TEMPO events, which will override your tempo setting. The overcome that, you need re-override the file's TEMPO events, which can be done via a BASS_SYNC_MIDI_EVENT sync. Something like this...

BASSMIDI.BASS_MIDI_StreamEvent(handle, 0, BASSMIDI.MIDI_EVENT_TEMPO, yourtempo); // apply your tempo setting
BASS.BASS_ChannelSetSync(handle, BASSMIDI.BASS_SYNC_MIDI_EVENT|BASS.BASS_SYNC_MIXTIME, BASSMIDI.MIDI_EVENT_TEMPO, TempoSync, 0); // and set a sync to override TEMPO events

BASS.SYNCPROC TempoSync=new BASS.SYNCPROC() {
public void SYNCPROC(int handle, int channel, int data, Object user) {
BASSMIDI.BASS_MIDI_StreamEvent(channel, 0, BASSMIDI.MIDI_EVENT_TEMPO, yourtempo); // apply your tempo setting
}
};

Please see the MIDITEST example for a more complete example of adjusting the tempo.
Logged
elimmedia
Posts: 11


« Reply #185 on: 13 Jul '12 - 07:56 »
Reply with quoteQuote

Hello Ian,

I have a question regarding BASS_MIDI again Cheesy

We have made sound font and apply into BASS.

It seems that exclusive class does not properly work on BASS.

For example, we have drumset and hi-hat need to be stereo.

we set two closed hi-hat on a same key with different pan for stereo and set the exclusive class 4 (both same)
we also set opened hi-hat(mono) with the same class 4 (different key)

What we were expecting is when closed hi-hat pressed, previous opened hi-hat need to be stopped.

Using this sound font, it works fine on general MIDI player, but BASS can sound only one side of closed hi-hat.

Please let us know if you have any idea for this.

Thank you in advance.

- Shin


Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #186 on: 13 Jul '12 - 14:42 »
Reply with quoteQuote

Please upload your soundfont to investigate what's happening here...

   ftp.un4seen.com/incoming/
Logged
elimmedia - shin
Guest
« Reply #187 on: 17 Jul '12 - 01:02 »
Reply with quoteQuote

I will make sound font shortly and send it to you. The one I send you has only drum set.

Beside the issue, I have another question for you.

I am curious if there is a way to protect custom soundfont.

ex.
1. encrypt a soundfont using MD5 and decrypt it when it is loaded.
2. custom soundfont has special header and check it on load.



Please upload your soundfont to investigate what's happening here...

   ftp.un4seen.com/incoming/
Logged
elimmedia-shin
Guest
« Reply #188 on: 17 Jul '12 - 02:36 »
Reply with quoteQuote

we actually found the solution regarding exclusive class.

we set exc class on only one side of closed hi-hat and it works.

We anyway sent you the soundfont file for you.

Thank you.

Please upload your soundfont to investigate what's happening here...

   ftp.un4seen.com/incoming/
Logged
rai2270
Posts: 5


« Reply #189 on: 17 Jul '12 - 06:33 »
Reply with quoteQuote

Hi,
When I use proguard to obfuscate my code, I've found out that my app will crash if Bass is in the project (and in use during runtime). When I remove Bass from the code (only Bass) and obfuscate again, all is OK.
I've tried to make it Bass will not be inside proguard, but it did not help.
Anyone got this problem?
Logged
rai2270
Posts: 5


« Reply #190 on: 17 Jul '12 - 06:44 »
Reply with quoteQuote

Well, to answer my own question:

put this in proguard.cfg:

-keep class com.un4seen.bass.** {
  public protected private *;
}
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #191 on: 17 Jul '12 - 17:51 »
Reply with quoteQuote

I am curious if there is a way to protect custom soundfont.

ex.
1. encrypt a soundfont using MD5 and decrypt it when it is loaded.
2. custom soundfont has special header and check it on load.

I think that should be possible using the undocumented option of loading a soundfont from memory, ie. you could decrypt your soundfont to memory and then pass that to BASSMIDI. The BASSMIDI Java class didn't include support for that feature, but I have put an update up in the 1st post which should do. You would decrypt your soundfont to a ByteBuffer and then pass that to BASS_MIDI_FontInit along with the BASS_MIDI_FONT_MEM flag. Let me know if you have any trouble with it.

Thanks for the test soundfont. I'll check if BASSMIDI is currently doing anything wrong with it.
Logged
elimmedia-shin
Guest
« Reply #192 on: 18 Jul '12 - 13:14 »
Reply with quoteQuote

Thank you for your quick update!

I have tested the new font load feature.

It loads up soundfont successfully, but sounds like crashed instruments.

I am also afraid if it is ok to allocate bytebuffer with huge size like 140MB.

We've used sampling chip which has 32MB capacity, but since we decided to use BASS MIDI and soundfont, we will make much better samplings.

The soundfont we've created is 25MB.

Below is the code for loading soundfont.

          private boolean initFont(String file){
      if(mSoundFont != 0)return true;
      ByteBuffer bb = null;
      try{
         File tempFile = new File(file);
         FileInputStream f = new FileInputStream( file );
         FileChannel ch = f.getChannel( );
         bb = ByteBuffer.allocate( (int)ch.size() );
         int read = 0;
         read = ch.read(bb);
         System.out.println("==== read check : "+tempFile.length() + " , " + read);
      }catch(Exception e){
         System.out.println("========= exception on load font : " + e);
         return false;
      }
      int newfont=BASSMIDI.BASS_MIDI_FontInit(bb, BASSMIDI.BASS_MIDI_FONT_MEM);
      if (newfont==0) {
         return false;
      } else {
         BASSMIDI.BASS_MIDI_FONT[] sf={new BASSMIDI.BASS_MIDI_FONT()};
         sf[0].font=newfont;
         sf[0].preset=-1; // use all presets
         sf[0].bank=0; // use default bank(s)
         BASSMIDI.BASS_MIDI_StreamSetFonts(0, sf, 1); // set default soundfont
         BASSMIDI.BASS_MIDI_StreamSetFonts(mHandle, sf, 1); // set for current stream too
         BASSMIDI.BASS_MIDI_FontFree(mSoundFont); // free old soundfont
         mSoundFont=newfont;
         return true;
      }
   }

I am curious if there is a way to protect custom soundfont.

ex.
1. encrypt a soundfont using MD5 and decrypt it when it is loaded.
2. custom soundfont has special header and check it on load.

I think that should be possible using the undocumented option of loading a soundfont from memory, ie. you could decrypt your soundfont to memory and then pass that to BASSMIDI. The BASSMIDI Java class didn't include support for that feature, but I have put an update up in the 1st post which should do. You would decrypt your soundfont to a ByteBuffer and then pass that to BASS_MIDI_FontInit along with the BASS_MIDI_FONT_MEM flag. Let me know if you have any trouble with it.

Thanks for the test soundfont. I'll check if BASSMIDI is currently doing anything wrong with it.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #193 on: 18 Jul '12 - 17:50 »
Reply with quoteQuote

I have tested the new font load feature.

It loads up soundfont successfully, but sounds like crashed instruments.

One possibility is that your ByteBuffer might be garbage collected, as it is local to the "initFont" function and BASS_MIDI_FontInit isn't currently incrementing its reference count. I'll make BASS_MIDI_FontInit increment the reference count in the next update, but to confirm whether that is the issue, please try moving the "bb" declaration outside of the function.

By the way, I think using "ByteBuffer.allocateDirect" instead of "ByteBuffer.allocate" will give better performance in reading the file to memory and BASSMIDI accessing it.

I am also afraid if it is ok to allocate bytebuffer with huge size like 140MB.

I guess that could be a problem. I think "Runtime.maxMemory" will tell how much memory is available to your process, but it is apparently possible to get around the limit by allocating memory in native code. If you happen to already be implementing some things in native code, you could try allocating the soundfont's memory there too. Implementing the decryption in native code would probably be a good idea too (faster than doing it in Java).

If you only need the soundfont's sample data to be encrypted, then another (more complex) option is to create a BASS add-on to decrypt the data.
Logged
elimmedia-shin
Guest
« Reply #194 on: 19 Jul '12 - 00:54 »
Reply with quoteQuote

I moved ByteBuffer declaration outside of the function, and it reduces the chance of crashed sound, but still produces the problem.

We just want our soundfont protected and plug-in option sounds good to us.

I had a chance to make some helloworld for JNI, but I am not a C coder.

If you give us a guideline or sample code for BASS plug-in, it would be much easier for me to try Cheesy



I have tested the new font load feature.

It loads up soundfont successfully, but sounds like crashed instruments.

One possibility is that your ByteBuffer might be garbage collected, as it is local to the "initFont" function and BASS_MIDI_FontInit isn't currently incrementing its reference count. I'll make BASS_MIDI_FontInit increment the reference count in the next update, but to confirm whether that is the issue, please try moving the "bb" declaration outside of the function.

By the way, I think using "ByteBuffer.allocateDirect" instead of "ByteBuffer.allocate" will give better performance in reading the file to memory and BASSMIDI accessing it.

I am also afraid if it is ok to allocate bytebuffer with huge size like 140MB.

I guess that could be a problem. I think "Runtime.maxMemory" will tell how much memory is available to your process, but it is apparently possible to get around the limit by allocating memory in native code. If you happen to already be implementing some things in native code, you could try allocating the soundfont's memory there too. Implementing the decryption in native code would probably be a good idea too (faster than doing it in Java).

If you only need the soundfont's sample data to be encrypted, then another (more complex) option is to create a BASS add-on to decrypt the data.
Logged
fulbert
Posts: 6


« Reply #195 on: 19 Jul '12 - 05:59 »
Reply with quoteQuote

Does BASS_ChannelSetSync with BASS_SYNC_META work for STREAMPROC_PUSH?

Seems to work for BASS_StreamCreateURL but if I use BASS_StreamCreate, SYNCPROC callback does not trigger.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #196 on: 19 Jul '12 - 13:37 »
Reply with quoteQuote

I moved ByteBuffer declaration outside of the function, and it reduces the chance of crashed sound, but still produces the problem.

A BASSMIDI update is up in the 1st post, in which BASS_MIDI_FontInit will increment the ByteBuffer's reference count (to prevent it being garbage collected before BASS_MIDI_FontFree is called). So you could give that a try and see if the problem still happens. If it does, does the problem not happen if you pass the soundfont's filename directly to BASS_MIDI_FontInit instead? If the problem is only happening with a particular soundfont, please upload that to have a look at.

The update also includes a fix for the exclusive class issue that you had with your soundfont.

We just want our soundfont protected and plug-in option sounds good to us.

I had a chance to make some helloworld for JNI, but I am not a C coder.

If you give us a guideline or sample code for BASS plug-in, it would be much easier for me to try Cheesy

The example BASS add-on code hasn't been updated for Android yet, but I'll get that updated and sent your way, hopefully by early next week. What language is your decryption code written in? Note an add-on will need to be written in C/C++.

Does BASS_ChannelSetSync with BASS_SYNC_META work for STREAMPROC_PUSH?

Seems to work for BASS_StreamCreateURL but if I use BASS_StreamCreate, SYNCPROC callback does not trigger.

No. BASS_SYNC_META syncs are triggered when metadata is received from Shoutcast servers, so they don't apply to custom streams (there is no metadata).
Logged
elimmedia-shin
Guest
« Reply #197 on: 19 Jul '12 - 15:26 »
Reply with quoteQuote

decryption code will be written in C/C++.

I really appreciate your quick response.

I moved ByteBuffer declaration outside of the function, and it reduces the chance of crashed sound, but still produces the problem.

A BASSMIDI update is up in the 1st post, in which BASS_MIDI_FontInit will increment the ByteBuffer's reference count (to prevent it being garbage collected before BASS_MIDI_FontFree is called). So you could give that a try and see if the problem still happens. If it does, does the problem not happen if you pass the soundfont's filename directly to BASS_MIDI_FontInit instead? If the problem is only happening with a particular soundfont, please upload that to have a look at.

The update also includes a fix for the exclusive class issue that you had with your soundfont.

We just want our soundfont protected and plug-in option sounds good to us.

I had a chance to make some helloworld for JNI, but I am not a C coder.

If you give us a guideline or sample code for BASS plug-in, it would be much easier for me to try Cheesy

The example BASS add-on code hasn't been updated for Android yet, but I'll get that updated and sent your way, hopefully by early next week. What language is your decryption code written in? Note an add-on will need to be written in C/C++.

Does BASS_ChannelSetSync with BASS_SYNC_META work for STREAMPROC_PUSH?

Seems to work for BASS_StreamCreateURL but if I use BASS_StreamCreate, SYNCPROC callback does not trigger.

No. BASS_SYNC_META syncs are triggered when metadata is received from Shoutcast servers, so they don't apply to custom streams (there is no metadata).
Logged
elimmedia
Posts: 11


« Reply #198 on: 19 Jul '12 - 15:59 »
Reply with quoteQuote

I have tested the new update and it has the same problem.

I also tried passing filename directly and has same problem too.

I moved back to old library just in case, and it sounds fine.



I moved ByteBuffer declaration outside of the function, and it reduces the chance of crashed sound, but still produces the problem.

A BASSMIDI update is up in the 1st post, in which BASS_MIDI_FontInit will increment the ByteBuffer's reference count (to prevent it being garbage collected before BASS_MIDI_FontFree is called). So you could give that a try and see if the problem still happens. If it does, does the problem not happen if you pass the soundfont's filename directly to BASS_MIDI_FontInit instead? If the problem is only happening with a particular soundfont, please upload that to have a look at.

The update also includes a fix for the exclusive class issue that you had with your soundfont.

We just want our soundfont protected and plug-in option sounds good to us.

I had a chance to make some helloworld for JNI, but I am not a C coder.

If you give us a guideline or sample code for BASS plug-in, it would be much easier for me to try Cheesy

The example BASS add-on code hasn't been updated for Android yet, but I'll get that updated and sent your way, hopefully by early next week. What language is your decryption code written in? Note an add-on will need to be written in C/C++.

Does BASS_ChannelSetSync with BASS_SYNC_META work for STREAMPROC_PUSH?

Seems to work for BASS_StreamCreateURL but if I use BASS_StreamCreate, SYNCPROC callback does not trigger.

No. BASS_SYNC_META syncs are triggered when metadata is received from Shoutcast servers, so they don't apply to custom streams (there is no metadata).
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #199 on: 19 Jul '12 - 17:28 »
Reply with quoteQuote

I have tested the new update and it has the same problem.

I also tried passing filename directly and has same problem too.

I moved back to old library just in case, and it sounds fine.

OK. That looks like it is a more general problem then, not related to loading from memory. There were some internal tweaks recently (more floating-point calculations changed to fixed-point), so the problem is probably somewhere in that stuff. To locate the problem, please upload your soundfont and a MIDI file to reproduce it with here...

   ftp.un4seen.com/incoming/
Logged
Pages: 1 ... 8 9 [10] 11 12 ... 18
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines