Author Topic: BASS for WinCE  (Read 372439 times)

Bergamin

  • Posts: 3
Re: BASS for WinCE
« Reply #150 on: 22 Sep '09 - 14:13 »
    
I'm using the CompactFramework 2.0.
Even the application is running normally.
It is this line and runs normal:
Code: [Select]
streamRec = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, myRecordProc, IntPtr.Zero);

Bergamin

  • Posts: 3
Re: BASS for WinCE
« Reply #151 on: 22 Sep '09 - 21:23 »
   
Using this example code on a HTC Touch (WM6), the recording is stopped suddenly after 20 seconds.

Anyone know why I respond?

Thank you!

Code: [Select]
private RECORDPROC _myRecProc; // make it global, so that the Garbage Collector can not remove it
...
Bass.BASS_RecordInit(-1);
_myRecProc = new RECORDPROC(MyRecording);
// start recording paused
int recChannel = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, _myRecProc, IntPtr.Zero);
...
// really start recording
Bass.BASS_ChannelPlay(recChannel, false);
...
// the recording callback
private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user)
{
  return true;
}



Code: [Select]
EncoderWAV wav = new EncoderWAV(recHandle);
wav.InputFile = null;
wav.OutputFile = "test.wav";

wav.Start(null, IntPtr.Zero, false);

// your recording will be encoded until you call...
wav.Stop();

jwinder

  • Guest
Re: BASS for WinCE
« Reply #152 on: 23 Sep '09 - 08:28 »
Can anyone here help with my issue in this thread: https://www.un4seen.com/forum/?topic=10332.0

Sorry, I might have been better posting it in this topic in the first place!

EEh

  • Posts: 6
Re: BASS for WinCE
« Reply #153 on: 23 Sep '09 - 14:29 »
Do either of the BASS_CONFIG_BUFFER and BASS_CONFIG_DEV_BUFFER settings make any difference with the updated DLL?

The only difference that I heard is that playback latency increased (I enlarged device buffer (up to 400-600ms from 200) and playback buffer (up to 1000ms from 500ms), also I ran tests in which  device buffer length equals playback buffer (400 - 500 ms) ). Sound breaks was audiable.

Quote
Do you happen to know what priority the WiFi/Bluetooth threads on your device are running at? Perhaps the problem is that they are running at a higher priority than the audio driver? Do you get the breaks in playback with any other software? If you haven't already done so, please also try to reproduce the problem with the pre-compiled examples.

I ran netradio example from package - it confirms a problem on my device. Also I descovered that BASS uses priority value 248 for playback and 250 (or 249?) for update in new version ( in old version was 249 and 250 respectively). On the other hand, MS windows media player (wmplayer.exe) uses 150 and 247 priority values and sound plays more clearly (1-2 sound breaks against 30 breaks from BASS player). Furthemore, player's behaviour tightly depends on device's vendor and OS firmware. I am using HTC with WM6.1 and Samsung with WM6.5 on board, and I need to  customize BASS player's threads priorities for each environment.

Can you introduce new config options to control BASS thread priorities? (NOTE: using of SetThreadPriority(THREAD_PRIORITY_TIME_CRITICAL) is not reasonable, beacause I want set up more higher priorities than 248 (with more lower value in Windows CE). See CeSetThreadPriority() for this case)

Quote
That's strange, as the only change in the update was the thread priority, which shouldn't affect that stuff. Is there any pattern to the problem, eg. a particular file or length of file? Also, is the BASS_ChannelPlay call always successful, ie. returning TRUE?

Yes, BASS_ChannelPlay returns TRUE, but sometimes playback does not starts after that. Playing the same data later may be successful. This problem is not always reproducible . I suppose, it may happen because of priority difference beetwen of playback and update threads (for example if update thread was forcing out from execution by playback).




Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for WinCE
« Reply #154 on: 23 Sep '09 - 16:04 »
Using this example code on a HTC Touch (WM6), the recording is stopped suddenly after 20 seconds.

To narrow-down where the problem is, please try to reproduce that with the pre-compiled RECTEST.EXE example.

I ran netradio example from package - it confirms a problem on my device. Also I descovered that BASS uses priority value 248 for playback and 250 (or 249?) for update in new version ( in old version was 249 and 250 respectively). On the other hand, MS windows media player (wmplayer.exe) uses 150 and 247 priority values and sound plays more clearly (1-2 sound breaks against 30 breaks from BASS player). Furthemore, player's behaviour tightly depends on device's vendor and OS firmware. I am using HTC with WM6.1 and Samsung with WM6.5 on board, and I need to  customize BASS player's threads priorities for each environment.

Can you introduce new config options to control BASS thread priorities? (NOTE: using of SetThreadPriority(THREAD_PRIORITY_TIME_CRITICAL) is not reasonable, beacause I want set up more higher priorities than 248 (with more lower value in Windows CE). See CeSetThreadPriority() for this case)

OK, an update with configurable priority of the device output thread is in the package now (see 1st post). It adds the following BASS_SetConfig option:

Code: [Select]
#define BASS_CONFIG_DEV_PRIORITY 31
That should be set before calling BASS_Init; subsequent changes won't take effect until the next BASS_Init call. It can be set between 1 and 255 (0=leave default: time critical), as described here:

   http://msdn.microsoft.com/en-us/library/bb202761.aspx

Please report how you get on with it.

Yes, BASS_ChannelPlay returns TRUE, but sometimes playback does not starts after that. Playing the same data later may be successful. This problem is not always reproducible . I suppose, it may happen because of priority difference beetwen of playback and update threads (for example if update thread was forcing out from execution by playback).

Was that with internet streams or local files? If the former, could it have been stalled, waiting for data to arrive? What does BASS_ChannelIsActive say about it?

EEh

  • Posts: 6
Re: BASS for WinCE
« Reply #155 on: 24 Sep '09 - 12:16 »

Yes, BASS_ChannelPlay returns TRUE, but sometimes playback does not starts after that. Playing the same data later may be successful. This problem is not always reproducible . I suppose, it may happen because of priority difference beetwen of playback and update threads (for example if update thread was forcing out from execution by playback).

Was that with internet streams or local files? If the former, could it have been stalled, waiting for data to arrive? What does BASS_ChannelIsActive say about it?

BASS_ChannelIsActive returns BASS_ACTIVE_STALLED.

I tested new version of updated dll and descover that update and playback threads must have EQUALS priorities, otherwise we have a bug described above (sometime playback does not starts and stalls after play).

Can you introduce config option for update thread priority too? (as it was done for device output).

NOTE that BASS at this time uses default settings for priorities (248 (output) and 249 (update)) that are not correctly working. (in inital version was 249 for both)
« Last Edit: 24 Sep '09 - 12:41 by EEh »

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for WinCE
« Reply #156 on: 24 Sep '09 - 14:27 »
BASS_ChannelIsActive returns BASS_ACTIVE_STALLED.

Was that with an internet stream or a local stream? If an internet stream, please check what BASS_StreamGetFilePosition (BASS_FILEPOS_BUFFER) says about the download buffer level.

I tested new version of updated dll and descover that update and playback threads must have EQUALS priorities, otherwise we have a bug described above (sometime playback does not starts and stalls after play).

Can you introduce config option for update thread priority too? (as it was done for device output).

NOTE that BASS at this time uses default settings for priorities (248 (output) and 249 (update)) that are not correctly working. (in inital version was 249 for both)

I'm not sure it's a good idea to set the update thread to a very high priority, as if it hogs the CPU it could effectively lock-up the device, eg. the GUI could become unresponsive due to getting no CPU and the user can't close the app. The same could be said for the device output thread, but that generally has less work to do, so it is less likely to hog the CPU. Btw, in the initial versions, the device output thread was actually accidentally a lower priority than the update thread (251 vs 249); they were never the same priority.

Are you able to monitor the CPU usage on your device, and if so, what does that say about the processes/threads?

EEh

  • Posts: 6
Re: BASS for WinCE
« Reply #157 on: 24 Sep '09 - 15:23 »
Was that with an internet stream or a local stream? If an internet stream, please check what BASS_StreamGetFilePosition (BASS_FILEPOS_BUFFER) says about the download buffer level.


I use BASS_StreamCreateFileUser to pump data from my own data storage. I want notice that I have a problem with playback only if playback thread priority is 248 or lower. I.e. when playback thread has priority as device driver. ( in CE time critical priority will be mapped to 249 ).

Quote
I'm not sure it's a good idea to set the update thread to a very high priority, as if it hogs the CPU it could effectively lock-up the device, eg. the GUI could become unresponsive due to getting no CPU and the user can't close the app. The same could be said for the device output thread, but that generally has less work to do, so it is less likely to hog the CPU. Btw, in the initial versions, the device output thread was actually accidentally a lower priority than the update thread (251 vs 249); they were never the same priority.

Are you able to monitor the CPU usage on your device, and if so, what does that say about the processes/threads?

Yes, its may be overhead for CPU, but I want to experement with it. At this time I use some hack to adjust update thread priority - I wrote some code that searches update thread, gets its thread id, converts ID to HANDLE (in CE are the same) and with using of CeSetThreadPriority sets priority value that I need. This approach is not convenient.
Ability to adjust this priority through BASS_SetConfig will be very usefull

« Last Edit: 24 Sep '09 - 15:38 by EEh »

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for WinCE
« Reply #158 on: 24 Sep '09 - 17:50 »
I use BASS_StreamCreateFileUser to pump data from my own data storage.

Which file system (STREAMFILE_xxx) are you using, and where is the data coming from? Have you confirmed that there is data available to decode when the problem(s) happen, ie. the problem isn't just a lack of data?

Please also try reproducing the problem with local files, eg. BASS_StreamCreateFile.

Yes, its may be overhead for CPU, but I want to experement with it. At this time I use some hack to adjust update thread priority - I wrote some code that searches update thread, gets its thread id, converts ID to HANDLE (in CE are the same) and with using of CeSetThreadPriority sets priority value that I need. This approach is not convenient.
Ability to adjust this priority through BASS_SetConfig will be very usefull

DSP functions run in the update thread, so one fairly simple way you could set its priority is to do so in a DSP function, set via BASS_ChannelSetDSP. DSP functions will also be called during pre-buffering in a BASS_ChannelPlay call, so the BASS_ChannelSetDSP call should be made after starting playback. You can remove the DSP after it has been called once (but not within the DSPPROC itself), as the priority will remain the same for the duration on the thread.

EEh

  • Posts: 6
Re: BASS for WinCE
« Reply #159 on: 25 Sep '09 - 13:01 »
Please also try reproducing the problem with local files, eg. BASS_StreamCreateFile.

I wrote simple test that confirms this problem and sent it to  admin@un4seen.com. Problem is reproduced only if sound output goes through bluetooth headphones (possible because of bluetooth driver latency)

Willem

  • Posts: 1
Re: BASS for WinCE
« Reply #160 on: 16 Oct '09 - 19:37 »
Hello,

I've been experimenting with Bass on my Windows Mobile device. I'm using Visual Studio 2005, mobile emulator and C#. I simply want to record a 8000khz 16bit mono PCM audio stream from my device.

I have run across a couple of problems and am wondering if any of you recognize these issues:
- when I call the BASS_Recordstart() method and I supply my callback function, it is never called.
- when I record audio manually using BASS_ChannelGetData() I am getting sound breaks in the resulting data. In this case I am using a Windows.threads.Timer to trigger the BASS_ChannelGetData(). The reported sound breaks are dependent on the interval that I specify when I create the timer. I get the feeling that BASS is easily pushed to the background in respect to other threads (or maybe just the UI thread). I would expect that the sound recording thread is per definition time critical.

What kind of things can I do to resolve these Issues?

Regards,
-- Willem

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for WinCE
« Reply #161 on: 19 Oct '09 - 16:35 »
Please try to reproduce the problem with the pre-compiled RECTEST.EXE example. If it happens with that too, I'll have to send you a debug version to get some further info.

Btw, the recording thread runs at above normal priority (THREAD_PRIORITY_ABOVE_NORMAL). I think that should generally be sufficient, as the thread just takes data from the recording buffer (which has been placed there by the driver) and then gives it to the RECORDPROC. The recording buffer is also 2 seconds long by default (see BASS_CONFIG_REC_BUFFER), so any short periods of CPU starvation shouldn't be a major problem, ie. no lost data.

Oscilloscope

  • Guest
Re: BASS for WinCE
« Reply #162 on: 9 Nov '09 - 02:23 »
Hi, does anybody knows how to implement oscope instead of Spectrum?

Thanks

Dondon

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for WinCE
« Reply #163 on: 9 Nov '09 - 16:00 »
The SPECTRUM example includes a waveform/oscilloscope mode (press on the screen a few of times to get to it).

dondon

  • Guest
Re: BASS for WinCE
« Reply #164 on: 11 Nov '09 - 03:36 »
Hi guys,

yeah the oscope is there :) sorry about that.

i got an this error in this new device. It is using Marvell, ARM920T-PX i think this is intel xcale, i can't run even a simple recording function in this device. it says this error.

File or assembly name 'Bass.Net.compact, Version = 2.4.1.1, Culture = neutral, PublicKeyToken = B7566C273E6EF480' or here is dependent on the file or assembly can not find one.

I tried this in another device but just this device has the error like this.

i need help guys.

thanks
Dondon

ken

  • Posts: 752
Re: BASS for WinCE
« Reply #165 on: 4 Dec '09 - 18:36 »
Does "BASS_StreamCreateURL" work on BassWinCE ?

I'm trying at Windows Mobile 6.5 play an mp3 internet stream (Shoutcast) but gets 0 in return.  BASS_StreamCreateFile  works just fine. I'm using Bass.Net.compact.
« Last Edit: 4 Dec '09 - 18:38 by ken »

ken

  • Posts: 752
Re: BASS for WinCE
« Reply #166 on: 4 Dec '09 - 18:51 »
Does "BASS_StreamCreateURL" work on BassWinCE ?

I'm trying at Windows Mobile 6.5 play an mp3 internet stream (Shoutcast) but gets 0 in return.  BASS_StreamCreateFile  works just fine. I'm using Bass.Net.compact.

Sorry, I think it's only my emulator that don't connect to internet. I have to wait and test until after the weekend when I get my new HTC HD2...

ken

  • Posts: 752
add-ons for BASS WinCE
« Reply #167 on: 5 Dec '09 - 10:07 »
Is there any add-ons that works with BASS WinCE?

Like BASSwma and BASSenc?

AlexFrance

  • Guest
Re: BASS for WinCE
« Reply #168 on: 6 Dec '09 - 11:53 »
Hello

I'm new to mobile dev so may be I'm missing something obvious...

I have VS2010/C# and I try to use BASS on a Windows mobile 6 pro emulator (without success...).
Adding Bass.Net.compact.dll reference is ok but no way to add bass.dll (ce version) reference ("can't add bass.dll reference" error message in VS).
And when I execute my app in the WM6 pro emulator, I get the following exception (when BASS_Init is called) :
"Can't find PInvoke DLL "bass.dll"" .
Can someone tell me what's the point ? Is there a way to link the bass.dll in my exe (before deploying it) ?

Thanks a lot!

radio42

  • Posts: 4839
Re: BASS for WinCE
« Reply #169 on: 6 Dec '09 - 13:18 »
It is pretty much like regular development.
You don't reference the bsss.dll in your project, you just need to make sure, that the bass.dll exists in your executable directory on the mobile device.
When using an emulator (and not a real device), you might need to copy the bass.dll to your emulator's folder manually, e.g. using the "Windows Mobile Device Center" application.

AlexFrance

  • Guest
Re: BASS for WinCE
« Reply #170 on: 6 Dec '09 - 13:47 »

yeah, quick and clear reply ! It works (just after figuring out how to copy/paste a file on WM)... Thanks a lot !!!

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for WinCE
« Reply #171 on: 7 Dec '09 - 15:58 »
Is there any add-ons that works with BASS WinCE?

Like BASSwma and BASSenc?

If you look closely, there are 3 of them in the package :)

BASSenc is one of them, but I'm afraid BASSWMA isn't as there doesn't seem to be a usable WMA decoder included in Windows Mobile. There is a DirectShow codec available to those that build their own WinCE platforms, and there is a slightly experimental "BASSDS" add-on available (on request) to make use of that, if anyone would like to do that.

ken

  • Posts: 752
Re: BASS for WinCE
« Reply #172 on: 7 Dec '09 - 16:48 »
Ok thanks Ian,

I just got my "HTC HD2" phone, and Bass WinCE works just fine. For now I have tested playing local mp3 and internetradio (mp3).

But I like to play wma files and wma internet stream.

ken

  • Posts: 752
Re: BASS for WinCE
« Reply #173 on: 7 Dec '09 - 16:51 »
to Bernd,

I use Bass.Net.compact, and play internetradio just fine. But I can't get update on TagInfo when the station change song. In your WinForm example in "MyDownloadProc" you use "Marshal.PtrToStringAnsi" to get the buffer. But "Marshal.PtrToStringAnsi" is not in the compact framework.

Any ideas how to get updated song info?

/Ken

radio42

  • Posts: 4839
Re: BASS for WinCE
« Reply #174 on: 8 Dec '09 - 08:02 »
You might use the Un4seen.Bass.AddOn.Tags.BassTags class in the CE version to get the tags.
Not, that song title changes are captures via:

Code: [Select]
// setup a meta sync to get the URL TAGs
Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_META, 0L, _metaSync, IntPtr.Zero);
...
private void MetaSync(int handle, int channel, int data, IntPtr user)
{
    TAG_INFO tags = new TAG_INFO();

    if (tags.UpdateFromMETA(Bass.BASS_ChannelGetTags(_stream, BASSTag.BASS_TAG_META), false, true))
    {
        // do what you need with the tag members
        // ...
    }
}