BASS for iOS (iPhone/iPad)

Started by Ian @ un4seen,

alexanderbaars

#1350
Quote from: Ian @ un4seenBASS_CONFIG_NET_AGENT should be set to a string. If you have an NSString, you can do this:

BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, [ua UTF8String]);

If there's still a problem, please confirm what string you're using, eg. any exotic characters?

I tried setting the NSString as UTF8String with no positive result.
De apache accesslog logs the useragent, if it is empty the file is served with a 206.
If it is "-" or something else the file is not servered and there is a 400 error logged.

Curiously the useragent logged in the server accesslog differs with every bass_init although the string logged in the app code does not.
The string used is "MyFantasticApp  2.2.7.0 (iphone) ", concatenated with device id:  XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
So there are dots, dashes and roundbrackets. I tried hardcoding it to "simpleuseragentstring" with the same result.

Can you please try using bass on iOS with this url:
[removed]

note: apache runs on windows server
with apache version 2.4.12, the useragent is not received correctly but the file is served nevertheless
with apache version 2.4.41 (win64) the useragent sometimes is empty (""), the file is served, sometimes "-" or other the file is not served.

Regards,

Alexander

Ian @ un4seen

If you try getting the BASS_CONFIG_NET_AGENT value back from BASS_GetConfigPtr afterwards, what do you see?

Also, what do you see in the Apache server log if you leave the default BASS_CONFIG_NET_AGENT setting?

alexanderbaars

Sorry for my late response. I had to test some more because I had eratic results.

If you leave out the setConfigPtr and log the useragent using getConfigPtr I get BASS/2.4 in the app log as well as in the server log.
The audio file is served perfectly.

If I use a hardcode string, something like "MyFantasticApp version 44". The firts few bass-inits seem to be oké.
But then, after some new bass_inits some random string is return on the getConfigPtr.
I found as a useragent string the certificate url crt.comodoca.com or other texts I would never send as a useragent string.
It seems like other headers replace the useragent header or something.

Sending an in-app string from another part of the app never succeeds. The string is logged correctly and the getConfigPtr in the setUserAgent method is correct. However when I check the getConfigPtr just before streamCreateUrl, in another method, the useragent seems to be nill.

I wonder if the http1.0 is due to that, since the ssl configuration demands a stricter header section on requests.

Ian @ un4seen

Please confirm what BASS version you are using (with BASS_GetVersion). Since 2.4.12, BASS_SetConfigPtr makes a copy of the provided string, so it should not be possible for it to become corrupted by itself. BASS_GetConfigPtr returns a pointer to the internal copy though, so you should not modify that (to avoid corrupting it).

alexanderbaars

BASS_GetVersion returns 33819402

I tried a newer version that returns 33820417, and: Audio is served. :D

I find useragent values like "" or "blic}s %{public}s%{public}s %{public}s %{public}s (%{public}@)]" in the server logs. ???

Ian @ un4seen

33819402 is 2.4.11.10, which means BASS_SetConfigPtr wasn't making a copy of the provided string. So that would explain why the string was getting corrupted (as the memory was reused for other things in the app).

alexanderbaars

Alright, thank you very much for your attention.

Regards,

Alexander Baars

reb

I have an issue with playing files downloaded by the new HDTracksDownloader in ALAC format.
I double checked to make sure all of the Bass components are current.
Opening the file over the network thusly:

channel = Bass.BASS_StreamCreateURL(url, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN | BASSFlag.BASS_STREAM_DECODE, null, IntPtr.Zero);

This returns Bass error 47, unstreamable.

It turns out these new files have the MOOV atom at the end.
Is there any way to make this work short of re-encoding the files on the server end?

Ian @ un4seen

If you have control over the server, I would suggest fixing the files at that end. You can use MP4Box to do that, like this: mp4box -isma <filename>

Otherwise, your app could download the file to disk/memory and then pass that to BASS_StreamCreateFile.


bagusflyer

Any sample code for iOS synth/midi/sound font>

Ian @ un4seen

There currently aren't any iOS examples provided but the BASS calls are the same on all platforms, so you could have a look at the examples included in the Windows/OSX/Linux packages and copy the interesting parts into your own code. In your case, you would want to check the MIDITEST.C and SYNTH.C examples included in the BASSMIDI package.

zhouhao

Get the following error message:

QuoteUse of unresolved identifier 'HIWORD'

In my code:

     
    var i = BASS_MIDI_FONTINFO()
    BASS_MIDI_FontGetInfo(font,&i)
     
    if i.presets == 1 { // only 1 preset, auto-select it...
        var p: DWORD = 0
        BASS_MIDI_FontGetPresets(font,&p)
       
        drums = (HIWORD(p)==128) // bank 128 = drums

Any idea? Thanks.

Ian @ un4seen

You can define HIWORD like this:

#define HIWORD(a) (WORD)((a)>>16)

bagusflyer

Is there any sample code to play a midi event in Swift or Objective-C in iOS?

bagusflyer

BASS_MIDI_StreamEvent(stream,1,MIDI_EVENT_NOTE,MAKEWORD(pitch,100)); // send note on/off event

No sound played. Any sample code to send note on/off event?

bagusflyer

Quote from: bagusflyerBASS_MIDI_StreamEvent(stream,1,MIDI_EVENT_NOTE,MAKEWORD(pitch,100)); // send note on/off event

No sound played. Any sample code to send note on/off event?

I solved the issue by adding the following code after sound font:

BASS_ChannelPlay(stream, false);

frankmail007

Can I apply DX8 effect in iOS to play midi note?

Here is my sample code:

  hfx = BASS_ChannelSetFX(stream, BASS_FX_DX8_I3DL2REVERB, 1);
 
  BASS_DX8_I3DL2REVERB effect;
 
  effect.flDecayHFRatio = 2;       // 0.1 - 2, default is 0.83
  effect.flDecayTime = 20;          // 0 - 20.0, default is 1.49
  effect.flDensity = 0.0;           // 0 - 100, default is 100.0
  effect.flDiffusion = 0.0;         // 0 - 100.0, defaut is 100.0
  effect.flHFReference = 20000.0;      // 20 - 20,000, default is 5000.0
  effect.flReflectionsDelay = 0.3;  // 0 - 0.3, default is 0.007
  effect.flReverbDelay = 0.1;        // 0 - 0.1, default is 0.011
  effect.flRoomRolloffFactor = 10;     // 0 - 10.0, default is 0
  effect.lReflections = 1000;        // -10,000 - 1000, default is -2602
  effect.lReverb = 2000;               // -10,000 - 2000, default is 200
  effect.lRoom = 0;               // -10,000 - 0, default is -1000
  effect.lRoomHF = 0;              // -10,000 - 0, default is -100
 
  BASS_FXSetParameters(hfx, &effect);

  BASS_ChannelPlay(stream, false);

  BASS_MIDI_StreamEvent(stream,1,MIDI_EVENT_NOTE,MAKEWORD(pitch,100));

But it seems no effect at all. Did I do anything wrong?


Chris

Hi as mentioned in the Bass helpfile
DX8 effects are a Windows feature requiring DirectX 8, or DirectX 9 for floating-point support.
On other platforms, they are emulated by BASS, except for the following which are currently unsupported: COMPRESSOR, GARGLE, and I3DL2REVERB.

frankmail007

Quote from: ChrisHi as mentioned in the Bass helpfile
DX8 effects are a Windows feature requiring DirectX 8, or DirectX 9 for floating-point support.
On other platforms, they are emulated by BASS, except for the following which are currently unsupported: COMPRESSOR, GARGLE, and I3DL2REVERB.

Based on the document, COMPRESSOR, GARGLE and I3DL2REVERB are not supported. But BASS_DX8_REVERB is also no effect. Any idea?

Ian @ un4seen

The BASS_DX8_REVERB effect should be supported on iOS. Please show your BASS_ChannelSetFX and BASS_FXSetParameters calls, and confirm their return values. Also try without BASS_FXSetParameters (to use the default settings), and see if that makes any difference.

frankmail007

Quote from: Ian @ un4seenThe BASS_DX8_REVERB effect should be supported on iOS. Please show your BASS_ChannelSetFX and BASS_FXSetParameters calls, and confirm their return values. Also try without BASS_FXSetParameters (to use the default settings), and see if that makes any difference.

Yes. It works now. Here is my code:

-(void)setReverb:(struct Reverb)reverb {
  hReverb = BASS_ChannelSetFX(stream, BASS_FX_DX8_REVERB, 1);
  if (hReverb) {
    BASS_DX8_REVERB effect;
    effect.fHighFreqRTRatio = reverb.highFreqRTRatio;  // 0.001 through 0.999. The default value is 0.001.
    effect.fInGain = reverb.inGain;               // -96 through 0. The default value is 0 dB.
    effect.fReverbMix = reverb.reverbMix;            // -96 through 0. The default value is 0 dB.
    effect.fReverbTime = reverb.reverbTime;        // 0.001 through 3000. The default value is 1000.

    BASS_FXSetParameters(hReverb, &effect);
    [self start];
  } else {
    [self showError];
  }
}


But I have another issue. It will generate huge amount of noise when I call the same function again with different parameters.

Ian @ un4seen

Are you calling BASS_ChannelSetFX again to create another instance of the effect, or only BASS_FXSetParameters to change the parameters of the existing effect? If the former, you will have reverb on top of reverb, which may be taking the level too high, resulting in clipping/distortion. To fix that, you could change the first line to this:

  if (!hReverb) hReverb = BASS_ChannelSetFX(stream, BASS_FX_DX8_REVERB, 1);

And make sure "hReverb" is initialized to 0.

zippo227

I'm getting an error about bitcode not being enabled. Can you put out a version with bitcode enabled? We're excited about a mobile port of our game Consortya using Unity iOS, different from the mobile version we tried in the past using Xamarin iOS.

zippo227

#1374
I made a github repo to help document how this is setup. With your help we can make it capable of running on Windows, macOS, Linux, iOS, and Android in Unity. Right now it is set up to export an iPhone build with bitcode disabled, but the build in xcode fails.

https://github.com/zippo227/unity-bass

Current error reported from the iPhone build build.

Undefined symbols for architecture arm64:
  "_vDSP_create_fftsetup", referenced from:
      _BASS_ChannelGetData in libbass.a(libbass.a-arm64-master.o)
  "_vDSP_fft_zip", referenced from:
      _BASS_ChannelGetData in libbass.a(libbass.a-arm64-master.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)