25 May '13 - 21:04 *
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 ... 21 22 [23] 24 25 ... 36
  Reply  |  Print  
Author Topic: BASS for iOS (iPhone/iPad)  (Read 110174 times)
Delphinus
Posts: 39


« Reply #440 on: 29 Mar '12 - 17:10 »
Reply with quoteQuote

I figured it out myself it was a just a problem related to my code.

Here's another question. In a custom stream is there a way to know where we are in a playing file like at what byte  I am reading?
I read that we can't get or set a position in a custom stream. So another way?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #441 on: 30 Mar '12 - 12:43 »
Reply with quoteQuote

It isn't possible to use BASS_ChannelSetPosition to seek (except forwards with the DECODETO flag) in a stream created with BASS_StreamCreate, but it is still possible to use BASS_ChannelGetPosition to get the current position.
Logged
Delphinus
Posts: 39


« Reply #442 on: 30 Mar '12 - 13:52 »
Reply with quoteQuote

Ok, so do you have any idea about how can I set the position of a custom stream with a seekable stream?
Logged
fxfletch
Posts: 12


« Reply #443 on: 30 Mar '12 - 13:54 »
Reply with quoteQuote

Hi,

I am working on my first project with Bass on the iPad and all working well part from I don't seem to be able to get my app to suppress audio from other apps.

I have set BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO,4) but emails still cause my audio to duck when they come in.

Am I missing something?

Thanks

Ian  
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #444 on: 30 Mar '12 - 15:36 »
Reply with quoteQuote

Ok, so do you have any idea about how can I set the position of a custom stream with a seekable stream?

You control what is fed to the stream through the STREAMPROC function, so you can have the STREAMPROC jump to another place in the source data, eg. move its read pointer. When doing that, you can clear the playback buffer by calling BASS_ChannelPlay (with restart=TRUE) or BASS_ChannelSetPosition (with pos=0), so that the new position is heard immediately. To avoid possible glitches mid-seek, you should also stop the stream first. So something like this...

BASS_ChannelStop(stream); // stop the stream
// seek here
BASS_ChannelPlay(stream, TRUE); // restart the stream

Note the stream's position will be reset to 0 when restarting, so you may want to retain the seek position and add that to what BASS_ChannelGetPosition reports.

I am working on my first project with Bass on the iPad and all working well part from I don't seem to be able to get my app to suppress audio from other apps.

I have set BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO,4) but emails still cause my audio to duck when they come in.

You could try setting BASS_CONFIG_IOS_MIXAUDIO to 0, which will result in the "audio session category" being set to kAudioSessionCategory_MediaPlayback, while 4 will result in kAudioSessionCategory_SoloAmbientSound. If that doesn't help, for comparison, do you have other apps that aren't affected by the incoming email sounds?
Logged
fxfletch
Posts: 12


« Reply #445 on: 30 Mar '12 - 15:43 »
Reply with quoteQuote

thanks for the reply,

I have tried both of those combinations with no luck, should this be set before BASS_INIT, I tried both anyway but it didn't seem to make any difference.

This is the first app I have on IOS my other Bass project was PC so I don't have anything to compare with.

Interestingly when an email comes in I don't actually here the sound its just that my audio briefly ducks.

Ian
Logged
Delphinus
Posts: 39


« Reply #446 on: 30 Mar '12 - 15:51 »
Reply with quoteQuote

Moving its read ponter means using fseek function i guess. If so which number do I have to use for the "offset" parameter in fseek? the number of byte of the decode stream via BASS_ChannelGetPosition with BASS_POS_BYTE flag or via the function StreamGetFilePosition?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #447 on: 30 Mar '12 - 16:15 »
Reply with quoteQuote

I have tried both of those combinations with no luck, should this be set before BASS_INIT, I tried both anyway but it didn't seem to make any difference.

This is the first app I have on IOS my other Bass project was PC so I don't have anything to compare with.

Interestingly when an email comes in I don't actually here the sound its just that my audio briefly ducks.

That sounds strange. Regarding other apps, I actually meant other apps that you have installed on the device. If the same thing doesn't happen with any of them, then we know that it is possible to avoid.

Regarding when to set the BASS_CONFIG_IOS_MIXAUDIO value, I would suggest before the BASS_Init call.

Moving its read ponter means using fseek function i guess. If so which number do I have to use for the "offset" parameter in fseek? the number of byte of the decode stream via BASS_ChannelGetPosition with BASS_POS_BYTE flag or via the function StreamGetFilePosition?

Is your stream feeding on a BASS "decoding channel", ie. the STREAMPROC is calling BASS_ChannelGetData on it? If so, you would seek by calling BASS_ChannelSetPosition on it, ie. the "seek here" in the code above would be a BASS_ChannelSetPosition call on the decoding channel
Logged
Delphinus
Posts: 39


« Reply #448 on: 30 Mar '12 - 17:11 »
Reply with quoteQuote

Hmmm How Can I explain all the thing I want to do....

I have two stream: One using StreamCreateFile with decode flag and applying TempoCreate pitch changed etc...
                             Another one using StreamCreate

I use the StreamCreate to perform scratching effect and the decode stream to playback file and do some effect, cue point and beat detection.

What I want is when I start scratching e.g as soon as I touch the jog button in my app I want to retrieve the exact position of the decode stream so I could start scratching to the correct position. Then when I stop scratching I want to set the position changed by the scratching on the decoded stream.

I think that in order to do that I have to match the position of the decode stream with the scratch stream but I don't know how...

I use this to do scratching effect http://blog.glowinteractive.com/wp-content/uploads/2011/01/AudioScratchDemo2.zip

I don't know if it's clear...
Logged
fxfletch
Posts: 12


« Reply #449 on: 1 Apr '12 - 15:28 »
Reply with quoteQuote

thanks for the reply,

I have tried both of those combinations with no luck, should this be set before BASS_INIT, I tried both anyway but it didn't seem to make any difference.

This is the first app I have on IOS my other Bass project was PC so I don't have anything to compare with.

Interestingly when an email comes in I don't actually here the sound its just that my audio briefly ducks.

Ian

Just to close the loop on this and for the benefit of others who are interested I have researched online and it looks like there is nothing you can do in your app to stop other alerts from causing the audio to duck. There is however a simple solution for the users and that's just to make sure the mute switch is set. This prevents any audio interruptions without affecting my apps audio output.

Ian
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #450 on: 2 Apr '12 - 15:37 »
Reply with quoteQuote

I have two stream: One using StreamCreateFile with decode flag and applying TempoCreate pitch changed etc...
                             Another one using StreamCreate

I use the StreamCreate to perform scratching effect and the decode stream to playback file and do some effect, cue point and beat detection.

What I want is when I start scratching e.g as soon as I touch the jog button in my app I want to retrieve the exact position of the decode stream so I could start scratching to the correct position. Then when I stop scratching I want to set the position changed by the scratching on the decoded stream.

I think that in order to do that I have to match the position of the decode stream with the scratch stream but I don't know how...

I use this to do scratching effect http://blog.glowinteractive.com/wp-content/uploads/2011/01/AudioScratchDemo2.zip

That code is decoding an audio file to memory (using BASS_StreamCreateFile + BASS_STREAM_DECODE) and then playing it from there (with scratching effect) using a custom stream (STREAMPROC). Do you basically want to add tempo processing to that? If so, you could try adding the BASS_STREAM_DECODE flag to the BASS_StreamCreate call, and then use that stream in a BASS_FX_TempoCreate call. That should be simpler than switching between 2 streams.

If you want/need to stick with switching between 2 separate streams, you can use BASS_ChannelGetPosition on the tempo stream to get its current position when switching to the scratching stream, but getting the position when switching the other way will be more complicated. You can use the scratching stream in a BASS_ChannelGetPosition call but translating that to a position for the tempo stream will be tricky; you would need to keep track of what data the scratching effect uses and use that information to translate the position.
Logged
Delphinus
Posts: 39


« Reply #451 on: 2 Apr '12 - 18:28 »
Reply with quoteQuote

Yes, I could add BASS_STREAM_DECODE etc to do tempo processing with my custom stream but I won't be able to set some cue point on it anymore (as we can't set position in a custom stream). So I think I have to stick with two separate streams and do the tricky thing.

Keeping track of what the scratching uses means that I have to store the data read by BASS_ChannelGetData right?

I'm not sure how to do that so what comes to my mind right now is to know what data i'm reading and at what position (in bytes) it corresponds in the mp3 file then take that position and re-read the file (using Bass_StreamCreateFile) at the correct offset? Sounds too tricky and greedy...
Logged
Delphinus
Posts: 39


« Reply #452 on: 5 Apr '12 - 11:12 »
Reply with quoteQuote

How can I know what data, read by BASS_ChannelGetData, corresponds in bytes?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #453 on: 5 Apr '12 - 17:41 »
Reply with quoteQuote

Keeping track of what the scratching uses means that I have to store the data read by BASS_ChannelGetData right?

Not store the data itself, but rather the source position where the data is from. You would need to retain that information for the last 500ms (or whatever BASS_CONFIG_BUFFER is set to) worth of data, and you can then use that information to translate the scratch stream position back into a source position for the tempo stream. The thing that makes that particularly tricky to do is that the scratching will probably involve rapidly changing direction and speed. You could try just taking the position at regular intervals in the data to get "close enough". On the other hand, I don't suppose the position will be very different at the end of the scratching from where it started if it's just going back and forwards, so perhaps you could even just resume the tempo stream from where it was?

Have you considered implementing the scratching using BASS_FX's reverse feature instead? That combined with some BASS_ATTRIB_FREQ manipulation could be used to implement a scratching effect, and you could then use the same stream for everything (reverse/scratch and tempo processing) rather than having 2 separate streams. Here's a thread on the subject...

   www.un4seen.com/forum/?topic=9754
Logged
Delphinus
Posts: 39


« Reply #454 on: 5 Apr '12 - 23:57 »
Reply with quoteQuote

Yes, I think I'll try what it is said on that thread and mix it with interpolation calculation. I'll let you know if I figure something out
Logged
SimonH
Posts: 7


« Reply #455 on: 11 Apr '12 - 21:30 »
Reply with quoteQuote

Hi,

I'm trying output an audio stream to file using Bassenc after messing with tempo and pitch.  I don't want to play the stream, just output to file but I'm having problems creating the encoder in the first place.

HSTREAM stream = BASS_StreamCreateFile(FALSE, [[assetURL relativePath] UTF8String], 0, 0, BASS_STREAM_DECODE);
HSTREAM fxStream = BASS_FX_TempoCreate(stream, BASS_STREAM_DECODE);
HENCODE encoder = BASS_Encode_StartCAFile(fxStream, 'mp4f', 'aac ', 0, 44100.0, [outputFilename cStringUsingEncoding:NSUTF8StringEncoding]);

encoder is equal to 0 at this point.

Any help would be very much appreciated.
« Last Edit: 12 Apr '12 - 07:16 by SimonH » Logged
SimonH
Posts: 7


« Reply #456 on: 12 Apr '12 - 08:10 »
Reply with quoteQuote

Sorry guys, figured it out with a little help from BASS_ErrorGetCode()  Embarrassed

There obviously shouldn't be a bitrate in the BASS_Encode_StartCAFile call when using aac.
« Last Edit: 12 Apr '12 - 08:41 by SimonH » Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #457 on: 12 Apr '12 - 14:30 »
Reply with quoteQuote

When the "bitrate" parameter is set to 0, the codec's default bitrate will be used, but if wanted, it should be possible to request a particular bitrate with AAC encoding. If your call above failed (with BASS_ERROR_NOTAVAIL), then 44100 probably isn't an accepted bitrate; that looks suspiciously like a sample rate Smiley

You could try 128000 for 128kbps, for example.
Logged
Delphinus
Posts: 39


« Reply #458 on: 12 Apr '12 - 16:33 »
Reply with quoteQuote

Hi,

Is there a way to have more than 20ms worth data with BASS_ChannelGetLevel function?. The values I retrieve with that function are good but I have too much data.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #459 on: 12 Apr '12 - 17:22 »
Reply with quoteQuote

There isn't currently any way to change the amount of data that BASS_ChannelGetLevel looks at, but BASS_ChannelGetLevel uses BASS_ChannelGetData internally and you could do the same to implement your own BASS_ChannelGetLevel function that looks at a different amount of data, ie. get the amount of data that you want and get the peak (highest absolute) sample levels from that. If you're dealing with a decoding channel (using the BASS_STREAM_DECODE flag) and you're happy with a multiple of 20ms, you could simply use multiple BASS_ChannelGetLevel calls and take the highest left and right level readings.
Logged
Pages: 1 ... 21 22 [23] 24 25 ... 36
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines