18 May '13 - 14:32 *
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 ... 6 7 [8] 9 10 ... 18
  Reply  |  Print  
Author Topic: BASS for Android  (Read 47695 times)
Ian @ un4seen
Administrator
Posts: 15244


« Reply #140 on: 19 Apr '12 - 14:48 »
Reply with quoteQuote

That's strange. If you look at the call stack in the debugger, what function call is the error message coming up on?
Logged
gnag
Posts: 160


« Reply #141 on: 23 Apr '12 - 19:18 »
Reply with quoteQuote

Hello,
again I am facing a Problem with things that work in the Windows Version but don't work in the Android/Java Version. Currently I want to use a SYNCPROC to call a Loop every X Seconds (1 Second currently) which produces a Tone.

After playing the Stream loopchannel which is feed from a STREAMPROC I can alread hear Sounds but when I try to set an SYNCPROC with 1 Second of Data as the Time to call it just doesn't get called, the debugger never steps into the line that says FreqChange(...), in Windows a similar Code works without Problem.

Maybe there is something special on Java again I missed.
Maybe something is getting Garbage collected or anything else is different?
If you need the full Code let me know, I can send it via PM because I don't want to post it all here.

private void DoSyncProc() {
// SyncProc
BASS.SYNCPROC mySync=new BASS.SYNCPROC() {
    public void SYNCPROC(int handle, int channel, int data, Object user) {
    //Play Next Tone
    // float freq_new = note_stack.iterator().next().Frequency;
    FreqChange(frequency+100);
    //Reset Channel
    BASS.BASS_ChannelSetPosition(handle, 0, BASS.BASS_POS_BYTE);
   
    }
   };
long nextPos = BASS.BASS_ChannelSeconds2Bytes(loopChannel, 1);
BASS.BASS_ChannelSetSync(loopChannel, BASS.BASS_SYNC_POS | BASS.BASS_SYNC_MIXTIME, nextPos, mySync, 0);
// int err = BASS.BASS_ErrorGetCode();
BASS.BASS_ChannelPlay(loopChannel, false);
}

Edit: I got the first problem solved (now it gets called after I called the SetSync before the ChannelPlay, on Windows the order of this calls doesn't have to be in that way, both ways work) however it does only get called once, does anyone know why?
« Last Edit: 24 Apr '12 - 17:07 by gnag » Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #142 on: 24 Apr '12 - 17:16 »
Reply with quoteQuote

Are you sure that the "nextPos" position is ahead of the current decoding position? Note it needs to be ahead of the decoding position, not just the currently heard position (which will be behind the decoding due to buffering). You can get the decoding position by using the BASS_POS_DECODE flag in a BASS_ChannelGetPosition call. If that is fine and the sync is still not working properly, please confirm how you're creating the "loopChannel" stream and what CONFIG settings you're using.
Logged
gnag
Posts: 160


« Reply #143 on: 24 Apr '12 - 17:28 »
Reply with quoteQuote

Thanks for your answer, yes I think it wasn't ahead of the current decoding Position because I was playing first and then calling the BASS_ChannelSetSync, I changed the order and it works now.

Also I was able to solve my second problem, the problem was that I was calling BASS_ChannelSetPosition with the handle of/from the SYNCPROC callback function instead of the channel handle so it didn't get reset and therefore was called only once, it works now like it should.
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #144 on: 24 Apr '12 - 17:55 »
Reply with quoteQuote

Oh yes, looking at your code again, it should be the "channel" handle that is used in the BASS_ChannelSetPosition call. Should have spotted that 1st time round Smiley
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #145 on: 4 May '12 - 14:49 »
Reply with quoteQuote

The latest BASS version (2.4.9) is now up in the 1st post.
Logged
Mr.Green2
Guest
« Reply #146 on: 4 May '12 - 19:46 »
Reply with quoteQuote

Android < 2.3 still doesn't see bass lib=(

Here is log:
05-04 22:42:34.909: D/dalvikvm(26812): Trying to load lib /data/data/app.name/lib/libbass.so 0x47ff68f8
05-04 22:42:34.926: I/dalvikvm(26812): Unable to dlopen(/data/data/app.name/lib/libbass.so): Cannot load library: link_image[1995]: failed to link libbass.so
05-04 22:42:34.926: W/dalvikvm(26812): Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lcom/un4seen/bass/BASS;.<clinit>
05-04 22:42:34.926: D/AndroidRuntime(26812): Shutting down VM
05-04 22:42:34.926: W/dalvikvm(26812): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
05-04 22:42:34.926: D/FlurryAgent(26812): Ending session

and then:

05-04 22:42:34.987: E/AndroidRuntime(26812): FATAL EXCEPTION: main
05-04 22:42:34.987: E/AndroidRuntime(26812): java.lang.ExceptionInInitializerError
...
05-04 22:42:34.987: E/AndroidRuntime(26812): Caused by: java.lang.UnsatisfiedLinkError: Library bass not found
05-04 22:42:34.987: E/AndroidRuntime(26812): at java.lang.Runtime.loadLibrary(Runtime.java:461)
05-04 22:42:34.987: E/AndroidRuntime(26812): at java.lang.System.loadLibrary(System.java:557)
05-04 22:42:34.987: E/AndroidRuntime(26812): at com.un4seen.bass.BASS.<clinit>(BASS.java:670)
05-04 22:42:34.987: E/AndroidRuntime(26812): ... 18 more

If I just change libbass.so to the old version - everything become allright.
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #147 on: 5 May '12 - 13:55 »
Reply with quoteQuote

Ah. That was probably introduced with the asset support, which appears to require Android 2.3. An update is now up in the 1st post, which should still work when asset support is unavailable (asset support will just be disabled then). Let me know if you still have any trouble loading it.
Logged
Mr.Green2
Guest
« Reply #148 on: 5 May '12 - 20:18 »
Reply with quoteQuote

Ah. That was probably introduced with the asset support, which appears to require Android 2.3. An update is now up in the 1st post, which should still work when asset support is unavailable (asset support will just be disabled then). Let me know if you still have any trouble loading it.
Thanks. Everything is working now!
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #149 on: 8 May '12 - 15:22 »
Reply with quoteQuote

The latest BASSmix version (2.4.7) is now up in the Android package, in the 1st post.
Logged
Mr.Green2
Guest
« Reply #150 on: 9 May '12 - 00:22 »
Reply with quoteQuote

Where can I read about new features and bug fixes in new release?
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #151 on: 9 May '12 - 17:12 »
Reply with quoteQuote

A changelog can be found in the "History" section of the text file (eg. BASS.TXT) included in the packages on the BASS webpage. That is also included in the documentation, which can be viewed online here:

   www.un4seen.com/doc/
Logged
rai2270
Posts: 5


« Reply #152 on: 10 May '12 - 21:56 »
Reply with quoteQuote

Hi. Is there example how to use the ByteBuffer return from BASS.BASS_ChannelGetData to display the spectrum of the sound?
I'm trying to create spectrum analyzer and will post the source code after that.
Thanks.
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #153 on: 11 May '12 - 16:23 »
Reply with quoteQuote

The ByteBuffer stuff could look something like this...

ByteBuffer bbuf=ByteBuffer.allocateDirect(1024*4); // allocate a buffer for the FFT data
bbuf.order(null); // little-endian byte order
BASS.BASS_ChannelGetData(handle, bbuf, BASS.BASS_DATA_FFT2048); // get the FFT data
int[] fft=new int[1024]; // allocate an "int" array for the FFT data
bbuf.asIntBuffer().get(fft); // get the data from the buffer into the array
// do something with the FFT data...

There isn't currently an Android version of the SPECTRUM example, but you could have a look at that example for the other platforms for some general ideas of what to do with the FFT data. Note that the data is in 8.24 fixed-point form on Android, hence "int" rather than "float", and 0x1000000 (1<<24) is equivalent to 1.0.
Logged
rai2270
Posts: 5


« Reply #154 on: 12 May '12 - 05:21 »
Reply with quoteQuote

Do you have a link to someone that implement the fft data in a graphic way? Thanks.
Logged
Slava
Guest
« Reply #155 on: 14 May '12 - 14:11 »
Reply with quoteQuote

For convenience, the stream/sample/music creation functions include support for assets, via an "Asset" class. For example, a stream could be created from a "music.ogg" asset like this...

stream = BASS.BASS_StreamCreateFile(new BASS.Asset(getAssets(), "music.ogg"), 0, 0, 0);


Is there a way to do the same in C++ not making any java calls from the user's code? Smiley
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #156 on: 14 May '12 - 15:43 »
Reply with quoteQuote

Do you have a link to someone that implement the fft data in a graphic way? Thanks.

I don't think there is any such example for Android at the moment, but you could have a look at the SPECTRUM example on the other platforms for some ideas.

For convenience, the stream/sample/music creation functions include support for assets, via an "Asset" class. For example, a stream could be created from a "music.ogg" asset like this...

stream = BASS.BASS_StreamCreateFile(new BASS.Asset(getAssets(), "music.ogg"), 0, 0, 0);

Is there a way to do the same in C++ not making any java calls from the user's code? Smiley

I'm not certain, but I don't think it will be possible to use the "BASS.Asset" Java class in a native app. I'm not sure if it is even possible to use assets in a native app, as an AssetManager instance (which the "getAssets" call above provides) is required, but if it is possible, you could load the asset to memory and then pass it to BASS_StreamCreateFile (with mem=TRUE).
Logged
Slava
Guest
« Reply #157 on: 14 May '12 - 22:04 »
Reply with quoteQuote


I'm not certain, but I don't think it will be possible to use the "BASS.Asset" Java class in a native app. I'm not sure if it is even possible to use assets in a native app, as an AssetManager instance (which the "getAssets" call above provides) is required, but if it is possible, you could load the asset to memory and then pass it to BASS_StreamCreateFile (with mem=TRUE).

Well, actually some examples could be found e.g. in SDL-1.3 source, where there're tricks such as accessing AssetManager or other Java classes through jni.
Also there's a number of tricks for getting the descriptor of the asset file and the position and size of a particular asset in the code which could be useful, provided it is not really compressed in the apk.

I'll try the mem=true way then Smiley
Logged
toob
Posts: 111


« Reply #158 on: 17 May '12 - 14:58 »
Reply with quoteQuote

Hi,

I've got a problem with the latest version of bass_fx.

I wanted the latest bass cause i wanted to use the new BASS.Asset(getAssets() feature which works fine. However I can no longer use bass_fx without an error even after downloading the lastest bass_fx,

I have opened the new bass_fx.java and can see the new stuff when comparing it to my previous version.
If I revert both bass and bass_fx then the errors go away but of course I cannot use BASS.Asset(getAssets().

The error in logcat is:
05-17 14:41:49.033: E/AndroidRuntime(28930): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load bass_fx: findLibrary returned null

I have not changed my calling code, but here my reverse play:
//reverse
if (Style==3){

BASS.BASS_ChannelRemoveFX(stream1, fxHandle);
BASS.BASS_StreamFree(stream1);

        if ((stream1=BASS.BASS_StreamCreateFile(quizstart.Tracks.get(CurrentQ).path, 0, 0, BASS.BASS_STREAM_DECODE|BASS.BASS_STREAM_PRESCAN))==0) {
Error("Can't play the file");
sb.setMax(0);
return;
}

        stream1 = BASS_FX.BASS_FX_ReverseCreate(stream1, 2f, BASS_FX.BASS_FX_FREESOURCE);
        BASS.BASS_ChannelSetAttribute(stream1,  BASS_FX.BASS_ATTRIB_REVERSE_DIR, -1f);

            long len = BASS.BASS_ChannelGetLength(stream1, BASS.BASS_POS_BYTE);
        BASS.BASS_ChannelSetPosition(stream1, (len/3), BASS.BASS_POS_BYTE);
        BASS.BASS_ChannelPlay(stream1, false);

int sometime=10;
sometime=Integer.parseInt(quizmain.ListPreference);

sb.setMax(sometime * 1000);
quiztime =0;
StopQuizTimerThread=false;
questionhandler.postDelayed(r, 100);

return;
} //reverse

Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #159 on: 17 May '12 - 15:42 »
Reply with quoteQuote

I just checked, and it seemed to be fine, ie. BASS_FX was loaded and the reverse processing applied, so that's strange. After replacing the SO and/or Java files, be sure to "Refresh" the corresponding project branch in Eclipse. If it's still not working after that, please confirm the date and size of the SO files in your app's APK file (it's a ZIP file). Also confirm which line the error message is appearing at; I guess it's the BASS_FX_ReverseCreate call?
Logged
Pages: 1 ... 6 7 [8] 9 10 ... 18
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines