Author Topic: BASS for Android  (Read 390020 times)

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #775 on: 4 Dec '14 - 04:13 »
But somehow the encoding using LAME is generating error:
Code: [Select]
12-03 12:39:39.073: A/libc(5375): Fatal signal 8 (SIGFPE) at 0x000014ff (code=-6), thread 5573 (com.pk.recaudio)

For some clues (hopefully), please also show the call stack from the crash.

Hi Ian,
Please find the trace below:
Code: [Select]
12-04 09:40:10.034: D/dalvikvm(5604): Trying to load lib /data/app-lib/com.pk.recaudio-1/libmp3lame.so 0x421ae758
12-04 09:40:10.034: D/dalvikvm(5604): Added shared lib /data/app-lib/com.pk.recaudio-1/libmp3lame.so 0x421ae758
12-04 09:40:10.034: D/dalvikvm(5604): No JNI_OnLoad found in /data/app-lib/com.pk.recaudio-1/libmp3lame.so 0x421ae758, skipping init
12-04 09:40:10.154: D/dalvikvm(5604): Trying to load lib /data/app-lib/com.pk.recaudio-1/libbass.so 0x421ae758
12-04 09:40:10.154: D/dalvikvm(5604): Added shared lib /data/app-lib/com.pk.recaudio-1/libbass.so 0x421ae758
12-04 09:40:10.234: I/Adreno-EGL(5604): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.2.2.1_RB1.04.04.04.090.026_msm8974_LNX.LA.3.5.2.2.1_RB1__release_AU ()
12-04 09:40:10.234: I/Adreno-EGL(5604): OpenGL ES Shader Compiler Version: E031.24.00.15
12-04 09:40:10.234: I/Adreno-EGL(5604): Build Date: 07/26/14 Sat
12-04 09:40:10.234: I/Adreno-EGL(5604): Local Branch:
12-04 09:40:10.234: I/Adreno-EGL(5604): Remote Branch: quic/LNX.LA.3.5.2.2.1_rb1
12-04 09:40:10.234: I/Adreno-EGL(5604): Local Patches: NONE
12-04 09:40:10.234: I/Adreno-EGL(5604): Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.2.2.1_RB1.04.04.04.090.026 +  NOTHING
12-04 09:40:10.264: D/OpenGLRenderer(5604): Enabling debug mode 0
12-04 09:40:10.334: V/RenderScript(5604): Application requested CPU execution
12-04 09:40:10.334: V/RenderScript(5604): 0x771c8a90 Launching thread(s), CPUs 4
12-04 09:40:10.394: I/Timeline(5604): Timeline: Activity_idle id: android.os.BinderProxy@421aa408 time:7561267
12-04 09:40:12.664: W/AudioRecord(5604): AUDIO_INPUT_FLAG_FAST denied by client
12-04 09:40:12.804: D/dalvikvm(5604): Trying to load lib /data/app-lib/com.pk.recaudio-1/libbassenc.so 0x421ae758
12-04 09:40:12.804: D/dalvikvm(5604): Added shared lib /data/app-lib/com.pk.recaudio-1/libbassenc.so 0x421ae758
12-04 09:40:12.804: D/dalvikvm(5604): No JNI_OnLoad found in /data/app-lib/com.pk.recaudio-1/libbassenc.so 0x421ae758, skipping init
12-04 09:40:12.834: D/rchan>(5604): -2147483647
12-04 09:40:12.894: D/rchan>(5604): -2147483647
12-04 09:40:12.904: A/libc(5604): Fatal signal 8 (SIGFPE) at 0x000015e4 (code=-6), thread 5732 (com.pk.recaudio)
12-04 09:40:13.404: D/LAME ENCODER(5604): encode the data
12-04 09:40:13.404: D/LAME ENCODER(5604): no ByteBuffer (null) = flush encoder
12-04 09:40:13.404: D/rchan>(5604): -2147483647
12-04 09:40:13.454: D/rchan>(5604): -2147483647
12-04 09:40:13.464: D/dalvikvm(5604): GC_FOR_ALLOC freed 5080K, 30% free 12771K/18180K, paused 12ms, total 13ms
12-04 09:40:13.504: D/LAME ENCODER(5604): no ByteBuffer (null) = flush encoder
12-04 09:40:13.504: D/rchan>(5604): -2147483647
12-04 09:40:13.554: D/rchan>(5604): -2147483647

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #776 on: 4 Dec '14 - 04:22 »
Hi Ian,
If you can let me know your FTP details, I can upload my project.
Once the issue is sorted out, you can use the project as a sample for your libraries, maybe...??

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #777 on: 4 Dec '14 - 06:29 »
Hi Ian,

Have uploaded my project to ftp.un4seen.com/incoming/
The file is: pkAudioRecorder.7z
It also includes the LAME libraries, JNI inclusive.

Please do have a look when free.
Thanx.
« Last Edit: 4 Dec '14 - 07:27 by Pranjal »

Amx-Vector

  • Posts: 2
Re: BASS for Android
« Reply #778 on: 4 Dec '14 - 13:04 »
Hi, I new member on forum :)
And I newbie to ;D
I want ask little something
I have created my android app using BASS
Everything worked fine but...
when i plugged my headset, the sound played in rear speaker, not in my headset..
I changed my volume to using volume button. And isn't increase Bass stream volume...
How to fix that problem ? ???

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #779 on: 4 Dec '14 - 17:04 »
Back to the crash, I can get it to crash when attempting gapless playback, it also has a tempo changer. It crashes about 1 in 10 times when it get to the end of the file, otherwise it works fine

Here is the player startup:

Code: [Select]
     
        //Load file
        if ((chan=BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_STREAM_DECODE))==0) {// NEEDED FOR TEMPO
            Utils.MyLog(-1,LOG,"Error opening file " + file);
            return false;
        }       

        //Get channel info
        BASS.BASS_CHANNELINFO binf = new BASS_CHANNELINFO();
        BASS.BASS_ChannelGetInfo(chan,binf);

        //Create mixer
        mixer = BASSmix.BASS_Mixer_StreamCreate(binf.freq,2,BASS.BASS_STREAM_DECODE);

        //Add channel
        BASSmix.BASS_Mixer_StreamAddChannel(mixer,chan,BASSmix.BASS_MIXER_NORAMPIN);

        //Save mixer handle for the callback function to use
        mixerOnly = mixer;
       
        //Creates a tempo somehow!
        mixer = BASS_FX.BASS_FX_TempoCreate(mixer,  BASS_FX.BASS_FX_FREESOURCE);
        BASS.BASS_ChannelSetAttribute(mixer, BASS_FX.BASS_ATTRIB_TEMPO,0);
       
        //Setup first sync
        sync = BASS.BASS_ChannelSetSync(chan, BASS.BASS_SYNC_END|BASS.BASS_SYNC_MIXTIME, 0, EndSync,0);

Now the callback:

Code: [Select]
static BASS.SYNCPROC EndSync=new BASS.SYNCPROC() {
        public void SYNCPROC(int handle, int channel, int data, Object user) {
         
            String file = getNextFilename();
           
            //Free???
            BASSmix.BASS_Mixer_ChannelRemove(chan);
            BASS.BASS_StreamFree(chan); 
           
            //Load new file
            if ((chan=BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_STREAM_DECODE))==0) {
                Utils.MyLog(-1,LOG,"Error opening file " + file);
            } 
         
            //Add the new channel, notice its mixerOnly, this is the handle before the BASS_FX_TempoCreate
            BASSmix.BASS_Mixer_StreamAddChannel(mixerOnly,chan,BASSmix.BASS_MIXER_NORAMPIN);
           
            //Reset the mixer positon
            BASS.BASS_ChannelSetPosition(mixer, 0,BASS.BASS_POS_BYTE);
           
            //Reset the sync
            sync = BASS.BASS_ChannelSetSync(chan, BASS.BASS_SYNC_END, 0, EndSync,0);

        }
    };

So this does work, but sometimes crashes.

The issue there is that it it unsafe for a "mixtime" SYNCPROC function to call BASS_StreamFree on its own channel. The BASS_SYNC_END sync should actually be set on the mixer rather than the source, so that it's triggered when the mixer reaches the end, which will also allow you to free the old source within the SYNCPROC. The code could be modified something like this...

Code: [Select]
     
...

        sync = BASS.BASS_ChannelSetSync(mixerOnly, BASS.BASS_SYNC_END|BASS.BASS_SYNC_MIXTIME, 0, EndSync,0);

...

 static BASS.SYNCPROC EndSync=new BASS.SYNCPROC() {
        public void SYNCPROC(int handle, int channel, int data, Object user) {
         
            String file = getNextFilename();
           
            //Free???
            BASS.BASS_StreamFree(chan); 
           
            //Load new file
            if ((chan=BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_STREAM_DECODE))==0) {
                Utils.MyLog(-1,LOG,"Error opening file " + file);
            } 
         
            //Add the new channel, notice its mixerOnly, this is the handle before the BASS_FX_TempoCreate
            BASSmix.BASS_Mixer_StreamAddChannel(mixerOnly,chan,BASSmix.BASS_MIXER_NORAMPIN);
           
            //Reset the mixer positon
            BASS.BASS_ChannelSetPosition(mixerOnly, 0,BASS.BASS_POS_BYTE);
        }
    };

Please find the trace below:
Code: [Select]
...

Unfortunately, that doesn't include the crash's call stack. Do you have a filter enabled in the LogCat window? If so, please remove that (set to "All messages"), and then you will hopefully be able to see the call stack.

I have created my android app using BASS
Everything worked fine but...
when i plugged my headset, the sound played in rear speaker, not in my headset..
I changed my volume to using volume button. And isn't increase Bass stream volume...

That sounds strange. To confirm that it isn't anything specific to what your app is doing, please see if you can reproduce it with one of the examples included in the BASS package. If it does happen with them too, is it also happening with any other apps?

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #780 on: 5 Dec '14 - 03:58 »
Hi Ian,

Yes, I had a filter enabled.
Please find the stack trace attached.

(By the way, the source that I had uploaded is in Eclipse on windows)
« Last Edit: 5 Dec '14 - 04:01 by Pranjal »

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #781 on: 5 Dec '14 - 13:46 »
From that log, it looks like there was a "division by 0" error in the LAME wrapper's encodeBuffer function. My guess is "channels" is 0 in this line...

Code: [Select]
outlen=lame_encode_buffer_interleaved(lame, inbuf, length/channels/sizeof(short), outbuf, maxout); // encode the data

Check that you have initialized the LAME encoder (via the wrapper's initEncoder function) before trying to feed data to it.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #782 on: 5 Dec '14 - 17:16 »
The latest BASSMIDI version (2.4.9) is now up in the 1st post.

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #783 on: 6 Dec '14 - 03:34 »
Hi Ian,

Have uploaded my project to ftp.un4seen.com/incoming/
The file is: pkAudioRecorder.7z
It also includes the LAME libraries, JNI inclusive.

Please do have a look when free.
Thanx.

Hi Ian,
Yes, I have initialized the LAME encoder.
Kindly have a look at the source code that I have uploaded as above.

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #784 on: 6 Dec '14 - 04:29 »
Hi Ian,

This is the code I am using..
Code: [Select]
static {
        System.loadLibrary("mp3lame");
    }
    private native void initEncoder(int numChannels, int sampleRate, int bitRate, int mode, int quality);
    private native void destroyEncoder();
    private native int encodeFile(String sourcePath, String targetPath);
    private native ByteBuffer encodeBuffer(ByteBuffer Buffer, int length, int maxout);
   
   
static final int FREQ = 44100;
static final int CHANS = 1;
int rchan; // recording channel
int chan; // playback channel
ByteBuffer recbuf; // recording buffer
int level = 0;
int lvl_Left = 0;
int lvl_Right = 0;
Handler handler = new Handler();
private Button btnPlay;
private Button btnRecord;
private Button btnLoad;
private Button btnTag;
int REQUEST_LOAD_FILE = 2;
String strFilename;

BASS.BASS_CHANNELINFO ci;
    Boolean isPlaying = false;
ByteBuffer encodedBuffer;

class RunnableParam implements Runnable {
Object param;
RunnableParam(Object p) { param=p; }
public void run() {}
}

/** display error messages */
@SuppressLint("DefaultLocale")
void Error(String es) {
/** get error code in current thread for display in UI thread */
String s = String.format("%s\n(error code: %d)", es, BASS.BASS_ErrorGetCode());
runOnUiThread(new RunnableParam(s) {
            public void run() {
        new AlertDialog.Builder(PKRecAudio.this)
    .setMessage((String)param)
    .setPositiveButton("OK", null)
    .show();
            }
});
}

BASS.RECORDPROC RecordingCallback = new BASS.RECORDPROC() {
    public boolean RECORDPROC(int handle, ByteBuffer buffer, int length, Object user) {
    return true; // continue recording
    }
};
   
BASSenc.ENCODERPROC EncodingCallback = new BASSenc.ENCODERPROC() {
        public int ENCODERPROC(int handle, int channel, ByteBuffer buffer, int length, int maxout, Object user) {
            encodedBuffer = encodeBuffer(length==-1?null:buffer, length, maxout); // flush upon closing (length=-1)
            buffer.clear(); // to make buffer ready for writing
            buffer.put(encodedBuffer); // to write the encoded MP3 buffer on the old PCM buffer
            return buffer.position();
        }
    };
   
    void StartRecording() {
    if (chan != 0) { // free old recording
    BASS.BASS_StreamFree(chan);
    BASS.BASS_RecordFree();
    BASS.BASS_Free(); // close output device before recording incase of half-duplex device
    chan = 0;
    BASS.BASS_RecordInit(-1);
    }
btnPlay.setEnabled(false);
  btnPlay.setTextColor(Color.GRAY);
btnLoad.setEnabled(false);
btnLoad.setTextColor(Color.GRAY);   
   
    /** Create a media file name */
timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
strFilename = new File(Environment.getExternalStorageDirectory(), sFolderName + timeStamp + "_pkrec.mp3").toString();
   
        /** Create Recording channel and start recording paused */
rchan = BASS.BASS_RecordStart(44100, 2, BASS.BASS_RECORD_PAUSE, RecordingCallback, 0);
        BASSenc.BASS_Encode_StartUser(rchan, strFilename, BASSenc.BASS_ENCODE_AUTOFREE, EncodingCallback, 0);
        if (rchan == 0) {
        Error("Couldn't start recording");
    return;
    }
        TextFile.setText(strFilename);
        BASS.BASS_ChannelPlay(rchan, false); // start the output
        btnRecord.setText("Stop");
        btnRecord.setTextColor(Color.parseColor("#0009FF"));
    }

    void StopRecording() {
    BASSenc.BASS_Encode_Stop(rchan);
BASS.BASS_ChannelStop(rchan);
rchan = 0;
btnRecord.setText("Record");
btnRecord.setTextColor(Color.parseColor("#0C356B"));
pkCreateChannel2Play();
isPlaying = false;
    }

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #785 on: 6 Dec '14 - 12:45 »
Hi Ian,

You were right. Missed the initEncoder in onCreate. Thanx.  :)

Are these the right params for initEncoder?
Code: [Select]
initEncoder(1, 44100, 128, 0, 90);

Now the app doesn't crash, but its some weird audio being recorded.  ???

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #786 on: 8 Dec '14 - 03:52 »
Hi Ian,

I am now using this code...
Code: [Select]
static final int FREQ = 16000;  //44100
static final int CHANS = 1;
static final int BITRATE = 128;
static final int MODE = 1;
static final int QUALITY = 2;

initEncoder(CHANS, FREQ, BITRATE, MODE, QUALITY);

But the audio is being recorded weird.
Please do check the attachment.
Thanx.

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #787 on: 8 Dec '14 - 05:34 »
Hi Ian,

Setting channels to 2 seems to have sorted it out.
Code: [Select]
static final int FREQ = 44100;
static final int CHANS = 2;
static final int BITRATE = 128;
static final int MODE = 1;
static final int QUALITY = 2;

initEncoder(CHANS, FREQ, BITRATE, MODE, QUALITY);

But there seems to some change in pitch.
Please check the attached file.
Thanx.
« Last Edit: 8 Dec '14 - 05:44 by Pranjal »

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #788 on: 8 Dec '14 - 06:33 »
Hi Ian,

Uploaded my final project to your FTP server (ftp.un4seen.com/incoming/).
Filename: pkAudioRecorder-issue.7z

Please check for the audio issue
Thanx.

alerma

  • Posts: 16
Re: BASS for Android
« Reply #789 on: 8 Dec '14 - 08:29 »
Hey Ian,

I am working on Hi-Res music player for Android, and though your BASS engine is absolutely amazing it definitely has a room for improvement in Hi-Res domain.

One of the areas I would request to improve is 8.24 fixed-point limitation. As far as I understand it is similar to iOS CoreAudio 'native' format where the first 8 bits represent the sign, so the audio data can use the rest 24 bits. As many Hi-Res audio formats support 32 bits depth (and more), the limit of 24 bits in audio path can be a bottleneck.

Is it possible for you to allow floating-point data on Android, or at least allow 1.31 fixed-point instead of 8.24?

I fully understand that 8.24 limit was created with performance issues in mind, but really most of modern mobile CPUs starting from ARMv7 include hardware FPU. Makes sense?

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #790 on: 8 Dec '14 - 16:43 »
Uploaded my final project to your FTP server (ftp.un4seen.com/incoming/).
Filename: pkAudioRecorder-issue.7z

Please check for the audio issue

I haven't tried the code myself, but to confirm whether the problem is in LAME (or the wrapper), do you get a clean recording if you write to a WAV file instead, ie. using BASS_Encode_Start with BASS_ENCODE_PCM? If the WAV file is fine, what happens if you use the LAME wrapper's encodeFile function to encode it to MP3?

Is it possible for you to allow floating-point data on Android, or at least allow 1.31 fixed-point instead of 8.24?

I fully understand that 8.24 limit was created with performance issues in mind, but really most of modern mobile CPUs starting from ARMv7 include hardware FPU. Makes sense?

That is something that I am considering, and I think there is a good chance that the Android libraries will switch to using floating-point, at least on the armeabi-v7a and x86 architectures. I think the armeabi architecture will need to primarily remain fixed-point for performance reasons though, which complicates matters, as behaviour should ideally be identical on all architectures of a single platform. I haven't looked into the consequences fully yet, but hopefully it will be possible to overcome any such issues to avoid the need for apps to have different code for different architectures.

alerma

  • Posts: 16
Re: BASS for Android
« Reply #791 on: 8 Dec '14 - 19:22 »
That is something that I am considering, and I think there is a good chance that the Android libraries will switch to using floating-point, at least on the armeabi-v7a and x86 architectures. I think the armeabi architecture will need to primarily remain fixed-point for performance reasons though, which complicates matters, as behaviour should ideally be identical on all architectures of a single platform. I haven't looked into the consequences fully yet, but hopefully it will be possible to overcome any such issues to avoid the need for apps to have different code for different architectures.

I am looking forward whenever you will be able to make this change!

Another question about Bass for Android: are there any optimizations for ARM/NEON/SIMD instructions?

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #792 on: 9 Dec '14 - 03:52 »
I haven't tried the code myself, but to confirm whether the problem is in LAME (or the wrapper), do you get a clean recording if you write to a WAV file instead, ie. using BASS_Encode_Start with BASS_ENCODE_PCM? If the WAV file is fine, what happens if you use the LAME wrapper's encodeFile function to encode it to MP3?

Hi Ian,

The result is the same with WAV also. The audio seems to have a pitch issue.

The MP3 recording using LAME with MediaRecorder is fine though, using the code from the Samsung sample.
The Samsung sample records to a RAW file and then encodes that to MP3.

This is what I use for WAV recording...
Code: [Select]
   BASS.RECORDPROC RecordingCallback = new BASS.RECORDPROC() {
     public boolean RECORDPROC(int handle, ByteBuffer buffer, int length, Object user) {
     return true; // continue recording
     }
    };

    void StartRecording() {
     if (chan != 0) { // free old recording
     BASS.BASS_StreamFree(chan);
     BASS.BASS_RecordFree();
     BASS.BASS_Free(); // close output device before recording incase of half-duplex device
     chan = 0;
     BASS.BASS_RecordInit(-1);
     }
    
btnPlay.setEnabled(false);
  btnPlay.setTextColor(Color.GRAY);
btnLoad.setEnabled(false);
btnLoad.setTextColor(Color.GRAY);  

     MakeOutputMediaFolder(sFolderName); // Create "PKrecord" folder if doesn't exist
    
     /** Create a media file name */
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
    
        /** Create Recording channel and start recording paused */
        rchan = BASS.BASS_RecordStart(44100, 2, BASS.BASS_RECORD_PAUSE, RecordingCallback, 0);
        strFilename = new File(Environment.getExternalStorageDirectory(), sFolderName + timeStamp + "_record.wav").toString();

        BASSenc.BASS_Encode_Start(rchan, strFilename, BASSenc.BASS_ENCODE_PCM|BASSenc.BASS_ENCODE_AUTOFREE, null, null);

        if (rchan == 0) {
         Error("Couldn't start recording");
    return;
   }
        TextFile.setText(strFilename);
BASS.BASS_ChannelPlay(rchan, false); // start the output
        btnRecord.setText("Stop");
        btnRecord.setTextColor(Color.parseColor("#0009FF"));
    }

The recorded audio samples are attached.
Thanx.
« Last Edit: 15 Dec '14 - 05:49 by Pranjal »

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #793 on: 9 Dec '14 - 14:28 »
Another question about Bass for Android: are there any optimizations for ARM/NEON/SIMD instructions?

Yes, there are.

The result is the same with WAV also.

That sounds like the problem may be occurring in the recording then, not the encoding. To check that it isn't caused by BASSenc, can you reproduce it with the RECTEST example included in the BASS package?

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #794 on: 12 Dec '14 - 03:52 »
That sounds like the problem may be occurring in the recording then, not the encoding. To check that it isn't caused by BASSenc, can you reproduce it with the RECTEST example included in the BASS package?

Hi Ian,

The RECTEST example is working fine.

In my case, I'm writing to file directly instead of to memory buffer.
I'm sure I've screwed up my code somewhere...  ???
« Last Edit: 12 Dec '14 - 04:04 by Pranjal »

JoeK

  • Posts: 22
Re: BASS for Android
« Reply #795 on: 12 Dec '14 - 04:04 »
hey mr Ian , my problem was solved about casting and encoding and it was from my side , thanks for ur help :).
now everything is ok , im able to cast both on shoutcast and localy(BASS_Encode_ServerInit...) , so i need to make the casting continous , by meaning , when the next song is starting the encoder stall because its (BASS_ENCODE_AUTOFREE) and the attached mixer is freed on each new song call , therefore i changed my encoding setup to be like this :

Code: [Select]
Bass.BASS_ChannelGetInfo(Mixer,binf)
MixerB = Mx.BASS_Mixer_StreamCreate(binf.freq, binf.chans,Mx.BASS_MIXER_NONSTOP) // the casting is continuing to cast and produce silence even if split is stalled.
Dim Split As Int = Bass.BASS_StreamCreate(binf.freq,binf.chans,Bass.BASS_STREAM_DECODE,-1,0)// -1 means push stream
Mx.BASS_Mixer_StreamAddChannel(MixerB,Split,Mx.BASS_MIXER_NORAMPIN)
Encoder = BEnc.BASS_Encode_StartUser(MixerB,File.DirDefaultExternal&"/temp.mp3",BEnc.BASS_ENCODE_AUTOFREE, EncCall.EncodingCallback, Null)

now im setting up a dsp callback :

Code: [Select]
ds.prebuf = Bass.BASS_ChannelSeconds2Bytes(Mixer, binf2.minbuf/1000) // tried Mixer or Chan (Chan is a decoding channel , Mixer is not)
Bass.BASS_ChannelPlay(MixerB, False)
Dsp = Bass.BASS_ChannelSetDSP(Chan,ds.DSPcallback,0,2)
BEnc.BASS_Encode_CastInit(....)

and here is my dsp callback :
Code: [Select]
public void DSPPROC(int handle, int channel, ByteBuffer buffer, int length, Object user) {
int i = BASS_StreamPutData(Chan, buffer, length);

if(i >= prebuf + length){
targbuf = i; // target the current level
           prebuf = 0 ; // finished prebuffering
           prevbuf = 0;
}else{
if (i < targbuf) { // buffer level is below target, slow down...
           rate = rate--;
           BASS_ChannelSetAttribute(Chan, BASS_ATTRIB_FREQ, rate);
           prevbuf = 0;
} else if (i > targbuf && i >= prevbuf){// '{ // buffer level is high and not falling, speed up...
           rate = rate++;
          BASS_ChannelSetAttribute(Chan, BASS_ATTRIB_FREQ, rate);
          prevbuf = i;
           
}
}
}// Chan is "mixer"
i is returning the amount of data.
calling bassgetdata the app freezes and restarts.
all i hear on casting side is white noise and the song is playing normally , tried to put just BASS_StreamPutData alone and same result , i hope this will not confuse u , and if u have a better idea about casting channels even if they stalled or freed and dont stop casting , thank u , best regards
« Last Edit: 12 Dec '14 - 04:09 by JoeK »

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #796 on: 12 Dec '14 - 17:01 »
The RECTEST example is working fine.

In my case, I'm writing to file directly instead of to memory buffer.
I'm sure I've screwed up my code somewhere...  ???

What happens if you modify the RECTEST example to use BASSenc? Something like this...

Code: [Select]
BASS.RECORDPROC RecordingCallback=new BASS.RECORDPROC() {
public boolean RECORDPROC(int handle, ByteBuffer buffer, int length, Object user) {
return true; // continue recording
}
};

...

void StartRecording() {
...
BASSenc.BASS_Encode_Start(rchan, filename, BASSenc.BASS_ENCODE_PCM|BASSenc.BASS_ENCODE_AUTOFREE, null, null);
}

now everything is ok , im able to cast both on shoutcast and localy(BASS_Encode_ServerInit...) , so i need to make the casting continous , by meaning , when the next song is starting the encoder stall because its (BASS_ENCODE_AUTOFREE) and the attached mixer is freed on each new song call...

Is there a particular reason that you are freeing the mixer? Couldn't you just free the sources but keep the same mixer going and leave the encoder/caster set on it?

JoeK

  • Posts: 22
Re: BASS for Android
« Reply #797 on: 12 Dec '14 - 23:58 »
Mixer is applying many sync proc for END , for Fadein , Fade out , so i cannot make it BASS_MIXER_NONSTOP , because the mixer still alive and i cant control it if the chan is pause or faded out ..... so i need another mixer , push stream is my only solution , so can u please provide me an example on how to put data to the push stream correctly via DSP callback? btw the white noise is heard only on the left channel , the right channel is too quiet with shoppy sound like the sound is repeating many times and pitched down , thank u
« Last Edit: 13 Dec '14 - 00:08 by JoeK »

Pranjal

  • Posts: 79
Re: BASS for Android
« Reply #798 on: 14 Dec '14 - 04:31 »
What happens if you modify the RECTEST example to use BASSenc? Something like this...
Code: [Select]
BASS.RECORDPROC RecordingCallback=new BASS.RECORDPROC() {
public boolean RECORDPROC(int handle, ByteBuffer buffer, int length, Object user) {
return true; // continue recording
}
};

...

void StartRecording() {
...
BASSenc.BASS_Encode_Start(rchan, filename, BASSenc.BASS_ENCODE_PCM|BASSenc.BASS_ENCODE_AUTOFREE, null, null);
}

Hi Ian,

That is exactly what I had done. (See the code I had posted previously)

http://www.un4seen.com/forum/?topic=13225.msg113058#msg113058

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: BASS for Android
« Reply #799 on: 15 Dec '14 - 13:22 »
Mixer is applying many sync proc for END , for Fadein , Fade out , so i cannot make it BASS_MIXER_NONSTOP , because the mixer still alive and i cant control it if the chan is pause or faded out ..... so i need another mixer , push stream is my only solution , so can u please provide me an example on how to put data to the push stream correctly via DSP callback? btw the white noise is heard only on the left channel , the right channel is too quiet with shoppy sound like the sound is repeating many times and pitched down , thank u

When casting, you want the stream to be continuous, so a single mixer feeding the caster is ideal (you can have other mixers plugged into that mixer if needed). So I think it would be best to try to solve whatever issues you're currently having when using a single mixer; please describe what they are.

That is exactly what I had done. (See the code I had posted previously)

http://www.un4seen.com/forum/?topic=13225.msg113058#msg113058

OK. If recording to memory is fine but recording to file isn't, then perhaps the problem is slow I/O. Does adding the BASS_ENCODE_QUEUE flag to the BASS_Encode_Start call make any difference? If you're writing the file to an SD card, you could also see if using a different SD card helps.