Author Topic: BASS for iOS (iPhone/iPad)  (Read 774224 times)

alexanderbaars

  • Posts: 13
Re: BASS for iOS (iPhone/iPad)
« Reply #1350 on: 4 May '20 - 11:31 »

BASS_CONFIG_NET_AGENT should be set to a string. If you have an NSString, you can do this:

Code: [Select]
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
« Last Edit: 15 May '20 - 09:02 by alexanderbaars »

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1351 on: 4 May '20 - 14:00 »
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

  • Posts: 13
Re: BASS for iOS (iPhone/iPad)
« Reply #1352 on: 6 May '20 - 09:15 »
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

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1353 on: 6 May '20 - 13:41 »
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

  • Posts: 13
Re: BASS for iOS (iPhone/iPad)
« Reply #1354 on: 6 May '20 - 14:29 »
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

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1355 on: 6 May '20 - 16:35 »
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

  • Posts: 13
Re: BASS for iOS (iPhone/iPad)
« Reply #1356 on: 7 May '20 - 07:30 »
Alright, thank you very much for your attention.

Regards,

Alexander Baars

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1357 on: 12 Jun '20 - 19:21 »
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

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1358 on: 15 Jun '20 - 14:54 »
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.

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1359 on: 16 Jun '20 - 15:23 »
Ok, thanks.

bagusflyer

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1360 on: 24 Jun '20 - 05:04 »
Any sample code for iOS synth/midi/sound font>

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1361 on: 24 Jun '20 - 14:56 »
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

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1362 on: 26 Jun '20 - 07:16 »
Get the following error message:

Quote
Use of unresolved identifier 'HIWORD'

In my code:

Code: [Select]
     
    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

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1363 on: 26 Jun '20 - 17:20 »
You can define HIWORD like this:

Code: [Select]
#define HIWORD(a) (WORD)((a)>>16)

bagusflyer

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1364 on: 29 Jun '20 - 10:44 »
Is there any sample code to play a midi event in Swift or Objective-C in iOS?

bagusflyer

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1365 on: 29 Jun '20 - 14:16 »
Code: [Select]
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

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1366 on: 29 Jun '20 - 14:37 »
Code: [Select]
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?

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

Code: [Select]
BASS_ChannelPlay(stream, false);

frankmail007

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1367 on: 30 Jun '20 - 04:38 »
Can I apply DX8 effect in iOS to play midi note?

Here is my sample code:

Code: [Select]
  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

  • Posts: 2216
Re: BASS for iOS (iPhone/iPad)
« Reply #1368 on: 30 Jun '20 - 13:58 »
Hi as mentioned in the Bass helpfile
Code: [Select]
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

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1369 on: 6 Jul '20 - 08:17 »
Hi as mentioned in the Bass helpfile
Code: [Select]
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

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1370 on: 6 Jul '20 - 13:27 »
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

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1371 on: 7 Jul '20 - 09:28 »
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.

Yes. It works now. Here is my code:

Code: [Select]
-(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

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1372 on: 7 Jul '20 - 16:07 »
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:

Code: [Select]
  if (!hReverb) hReverb = BASS_ChannelSetFX(stream, BASS_FX_DX8_REVERB, 1);

And make sure "hReverb" is initialized to 0.

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1373 on: 8 Aug '20 - 19:26 »
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

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1374 on: 8 Aug '20 - 19:30 »
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)
« Last Edit: 8 Aug '20 - 21:07 by zippo227 »