22 May '13 - 08:29 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
  Home Help Search Login Register  
  Show Posts
Pages: [1] 2
1  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 23 Jan '12 - 20:16
-
ReplyReply Reply with quoteQuote
2  Developments / BASS / Bass MIDI: reading a midi file into a data structure? on: 10 Oct '11 - 01:06
Hi - this probably isn't a BASS specific question but I thought I would ask for some input.

I have a music learning app (iOS) that plays a midi file and takes input from an attached USB midi keyboard. I need to be able to compare/score the keyboard notes against the midi file notes in real time and determine if the keyboard notes are correct and are within an app specified time window (say +/- 1500 ms).

I have this working but I'm not satisfied with my implementation (basically buffering file + keyboard notes w/ timeStamps in separate, limited arrays and then walking the file note array with the user note). It seems like it would be so much better (efficient) to have a lookup table representing the midi file note data and then just check the incoming keyboard notes against that by timestamp or note value.

It doesn't seem possible to derive this sort of midi data structure from Bass (afaik) but if I use some external midi parsing code I might be able to set that up. Before I embark on that - does anyone think this would be a cruise to nowhere or know of a better way to correlate these two note streams?

thanks for any thoughts!
ReplyReply Reply with quoteQuote
3  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 26 Sep '11 - 18:08
Thanks. @ BASS_CONFIG_UPDATETHREADS - The docs say that the number of update threads is limited to 1 on the iOS. Is this an undocumented feature?
 
ReplyReply Reply with quoteQuote
4  Developments / BASS / Re: Filter Midi notes from BASS_MIDI_StreamCreateFile (iOS) on: 26 Sep '11 - 17:47
Yes, that works (in iOS).

Thanks for the quick reply!
ReplyReply Reply with quoteQuote
5  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 26 Sep '11 - 07:17
This is what I use:

const char *soundFontFile = [[[NSBundle mainBundle] pathForResource:@"ChoriumRevA.SF2" ofType:@""] UTF8String];

Here's a little bit @ converting between char arrays + NSString objects

http://iphonedevelopertips.com/c/converting-between-c-and-objective-c-strings.html
ReplyReply Reply with quoteQuote
6  Developments / BASS / Filter Midi notes from BASS_MIDI_StreamCreateFile (iOS) on: 26 Sep '11 - 00:38
Hi - I need to filter midi from a stream created through BASS_MIDI_StreamCreateFile.

I searched the forums and found this old thread:
http://www.un4seen.com/forum/?topic=7914.msg53930#msg53930

The method described there sort of works but I still hear the midi file playing faintly muted. I am using the exact code from the earlier post to test this (below). Any tips on why this may not be working?

BASS_ChannelSetSync(midi, BASS_SYNC_MIDI_EVENT|BASS_SYNC_MIXTIME, MIDI_EVENT_NOTE, PianoFilter, 0); // set NOTE event sync

...

void CALLBACK PianoFilter(HSYNC handle, DWORD channel, DWORD data, void *user)
{
if (!HIBYTE(data)) return; // it's a "note off", nothing to do
if (BASS_MIDI_StreamGetEvent(channel, HIWORD(data), MIDI_EVENT_DRUMS)) return; // ignore drum channels
DWORD preset=BASS_MIDI_StreamGetEvent(channel, HIWORD(data), MIDI_EVENT_PROGRAM); // get current preset
if (preset<9) // it's a piano
BASS_MIDI_StreamEvent(channel, HIWORD(data), MIDI_EVENT_NOTE, LOBYTE(data)); // release note (velocity=0)
}
ReplyReply Reply with quoteQuote
7  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 25 Sep '11 - 21:26
For the lowest latency output, you can disable buffering on a stream via the BASS_ATTRIB_NOBUFFER attribute/setting. When doing that, the BASS_CONFIG_UPDATEPERIOD and BASS_CONFIG_BUFFER settings will have no bearing on latency, but BASS_CONFIG_BUFFER should still not be set too low. Note that a stream's processing should avoid introducing any delays when BASS_ATTRIB_NOBUFFER is enabled, so it may not be ideal for a MIDI stream, eg. if it might have to load samples from a soundfont (which would introduce a delay).

Note none of the above affects the MIDI input stuff; a MIDIINPROC function is called as soon as MIDI data is received from the MIDI device/driver.

Regarding the Aug 30/11 update, that was BASS 2.4.8 Smiley

Thanks! I've set the update period to the minimum (5 ms) and the config buffer to the the reported device min for iPad (24 ms). I also enabled the no buffer attrib. There is no processing on the MIDI-IN data - it is routed directly to the playback stream.

I'm seeing @ 30 ms latency - which is better than it was. Is there anything else to set? I am using the sound font linked from the Bass site ("ChoriumRevA"). Is there any 'preload samples' type setting to avoid delay there? Any Core Midi settings that could be tweaked?
ReplyReply Reply with quoteQuote
8  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 25 Sep '11 - 21:19
Check your header paths under Build Settings. There may be some leftover chum in there if you added and deleted any of those addons.
ReplyReply Reply with quoteQuote
9  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 24 Sep '11 - 09:32
Doesn't look like you linked in the necessary iOS frameworks:

-CoreMidi
-CFNetwork
-AudioToolBox
-SystemConfiguration

ReplyReply Reply with quoteQuote
10  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 9 Sep '11 - 14:57
Hi, I'm reading through the docs and wondering what the lowest latency settings would be for midi i/o on iOS? Right now I'm using some code from the docs. Would decreasing the buffer help or hurt?

   if (!BASS_Init(-1,44100,BASS_DEVICE_LATENCY,NULL,NULL)) {
NSLog(@"Can't initialize device");
return;
}
    
DWORD len=BASS_GetConfig(BASS_CONFIG_UPDATEPERIOD); // get update period
BASS_INFO info;
BASS_GetInfo(&info); // retrieve device info
len+=info.minbuf; // add the 'minbuf'
BASS_SetConfig(BASS_CONFIG_BUFFER, len*1.5); // set the buffer length

EDIT
I've made some changes that seem to reduce the Midi in latency
--8 bit Midi in stream (not sure if this works on iOS)
--5 ms Bass update period
--buffer set to device min (24 ms)
--playback buffering disabled

Am I going in the right direction with these settings? Anything else I can adjust?

Also, I notice there is an Aug 30/11 update. What changed?

thanks!

ReplyReply Reply with quoteQuote
11  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 5 Sep '11 - 18:32
Yay! That works. Thanks!
ReplyReply Reply with quoteQuote
12  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 5 Sep '11 - 16:51
Need a bit more help here.

I've got Bass Midi in working with a keyboard - and using the MIDIINPROC example function, pass the midi data to a stream using:
BASS_MIDI_StreamEvents(midiInStream, BASS_MIDI_EVENTS_RAW, buffer, length);

That works fine - can hear the keyboard events, etc. but I need to get the MIDI_NOTE_EVENTS - either through a sync or through parsing the buffer. Since syncs don't work with BASS_MIDI_EVENTS_RAW, is there a code example around for parsing the buffer into BASS_MIDI_EVENTs?

The code below fails but this is the sort of thing I am looking for:
for(int i = 0; i < length; i++){
   DWORD data = buffer[i];
    int note=LOBYTE(data); // note
    int velocity=HIBYTE(data); // velocity
}
I realize this is probably more a basic programming question than a Bass question but any tips would be appreciated!

Oh - @Device 0 on iPad: apparently that has something to do with a network session. BASS_MIDI_InGetDeviceInfo returns "Session 1" as the device name.

thanks!
ReplyReply Reply with quoteQuote
13  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 25 Aug '11 - 22:58
Thanks. I was just looking at the 'BASS_GetDeviceInfo' docs in bass.chm and saw this note:
 
Quote
Remarks
This function can be used to enumerate the available devices for a setup dialog. Device 0 is always the "no sound" device, so you should start at device 1 if you only want to list real output devices.

Don't know what a 'no sound device' is - some system MIDI default/standard I guess so midi connect code doesn't fall over.

@ the retaining detached device names: out of curiosity/completeness, is it safe to assume that if a different device is attached to the same port and the ports are enumerated again, that Bass will update it's list with the new device name?

ReplyReply Reply with quoteQuote
14  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 23 Aug '11 - 19:02
Hi - finally got a chance to test midi in on iPad -iOS 4.3.5, with a USB keyboard (powered separately) using the iPad Camera Connector. It's working but there are a few things that may be odd. I'm using the code below (cobbled together from the OSX midi demo) and logging some of the info. The method is called through a button press - so everything has been loaded.

found device: 2
flags: 1
id: 1639062281
Bass Error: 23
name: USB Keystation 49e
Bass Init Success device: 1
Bass Init Success Error: 0

--I get the BASS_DEVICE_ERROR (23) whether or not the keyboard is attached. Is this correct?

--the keyboard is found at device index 1 - but the docs seem to indicate that device indexes start at 0?

--if I comment out the 'BASS_MIDI_InInit' code section below, it will recognize the keyboard (as expected) but if I then detach the keyboard and call the method again, it is still reporting the keyboard as found. That seems wrong.

Hope these details are useful. Other than my confusion (or wrong implementation) @ the above - midi in works just fine!


-(void) checkForInputDevice
{
    BASS_MIDI_DEVICEINFO di;
    int d;
    int err;
    for (d=0; BASS_MIDI_InGetDeviceInfo(d, &di); d++)
    {
       // nothing
    }
   
    if (d) {
        NSLog([NSString stringWithFormat:@"found device: %d", d]);
        NSLog([NSString stringWithFormat:@"flags: %d", di.flags]);
        NSLog([NSString stringWithFormat:@"id: %d", di.id]);
        err = BASS_ErrorGetCode();
        NSLog([NSString stringWithFormat:@"Bass Error: %d", err]);
       
        [owner setConnectionStatusResult:[NSString stringWithFormat:@"found device: %d", d]];
        [owner setConnectionStatusResult:[NSString stringWithFormat:@"flags: %d", di.flags]];
        [owner setConnectionStatusResult:[NSString stringWithFormat:@"id: %d", di.id]];
        [owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Error: %d", err]];
       
        CFStringRef cs=CFStringCreateWithCString(0,di.name,0);
        [owner setConnectionStatusResult:[NSString stringWithFormat:@"name: %@", cs]];
        CFRelease(cs);
   
            int a;
             for (a=1;a<d;a++) {
//            for (a=0;a<d;a++) { //***********NOTE CHANGE
                if (BASS_MIDI_InInit(a, RPMidiInProc, self)) {
                    BassMidiInput=a;
                    BASS_MIDI_InStart(BassMidiInput);
                     [owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Init Success device: %d", a]];
                    err = BASS_ErrorGetCode();
                    [owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Init Success Error: %d", err]];
                    break;
                } else {
                err = BASS_ErrorGetCode();
                [owner setConnectionStatusResult:[NSString stringWithFormat:@"Bass Init error: %d", err]];
                }
            }
 
    } else {
        [owner setConnectionStatusResult:[NSString stringWithFormat:@"no device"]];
        NSLog([NSString stringWithFormat:@"no device"]);
    }
}
ReplyReply Reply with quoteQuote
15  Developments / BASS / Timer/MIDI clock implementation suggestions on iOS? on: 17 Aug '11 - 17:41
Hi - I'm tinkering with a MIDI sequencer idea and need a clock. I'm combing through past forum posts and have seen mention of a "Bass Timer" but don't see that anywhere in the docs. Am I misreading this or is it deprecated?

This is for iOS. I could use NSTimer but the accuracy is loose from what I read. I could use a thread, once I learn how to do that...

Is there a standard way for getting accurate timing on iOS/OSX for doing things like a MIDI sequencer. I'm not looking for pro musician timing necessarily (unless it is not too hard to implement).

The gist of the functionality is pretty simple: at specified intervals (e.g. 100 ms) a number of arrays are checked for events to be played. These are collected into an array and sent out using 'BASS_Stream_Events'
ReplyReply Reply with quoteQuote
16  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 16 Aug '11 - 16:08
That was my bad - using an older lib. With the latest it compiles without complaint. Yay!

Any suggestions (or standards) on implementation? e.g.

-- poll using ' BASS_MIDI_InGetDeviceInfo' to ennumerate n ports (n = ? some reasonable value)
-- if one device found, InInit/InStart, else offer user a menu
-- detecting disconnection? -> check errorCode on each 'BASS_MIDI_StreamEvents' call; if error then InStop/InFree
-- resume polling

Does that sound reasonable?
ReplyReply Reply with quoteQuote
17  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 16 Aug '11 - 02:55
Trying MIDI in with Bass iOS - I get 'Undefined symbols' errors for all the MIDI in calls.

Undefined symbols for architecture i386:
  "_BASS_MIDI_InGetDeviceInfo", referenced from:
      -[BassController getDeviceInfo] in BassController.o

  "_BASS_MIDI_InInit", referenced from:
      -[BassController getDeviceInfo] in BassController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
ReplyReply Reply with quoteQuote
18  Developments / BASS / Re: BASS for iOS (iPhone/iPad) on: 10 Aug '11 - 17:26
Thanks. I finally saw in the docs that 'BASS_MIDI_StreamEvent' didn't support sync.

I was finally able to get things working with the code below - getting MIDI packets (CoreMidi) from a keyboard attached to an iPad through a Camera Connector and repackaging the data in the BASS_MIDI_EVENT struct format. Not pretty I guess but it works. Is there a better way to do this? I tried the 'BASS_MIDI_EVENTS_RAW' mode but that didn't work. I think I'm going to run into some issues with non-key midi events.

Since iOS now supports midi in, are there any plans to add that to Bass?

Thanks for the help!

- (void) MidiIn:(const MIDIPacketList*)packetList
{
    int len = packetList->numPackets;
    const MIDIPacket *packet = &packetList->packet[0];
    BASS_MIDI_EVENT events[len];
   
    for (int i = 0; i < len; ++i)
    {
        events[i].event = MIDI_EVENT_NOTE;
        events[i].param=MAKEWORD(packet->data[1], packet->data[2]);
        events[i].chan=0;
        packet = MIDIPacketNext(packet);
    }
   
    BASS_MIDI_StreamEvents(chanIn, BASS_MIDI_EVENTS_SYNC, events, len);
}
ReplyReply Reply with quoteQuote
19  Developments / BASS / Re: BASS_MIDI_StreamEvents - "Undefined symbol" error on iOS - I'm stumped on: 9 Aug '11 - 18:01
Yes, that works as expected. Thanks!

Could these issues be at all connected to my not getting sync calls for events specified using 'BASS_MIDI_StreamEvents'? I posted @ this in the iOS thread. Is something not wired up? I get sync events just fine using 'BASS_MIDI_StreamCreateFile'.
ReplyReply Reply with quoteQuote
20  Developments / BASS / Re: BASS_MIDI_StreamEvents - "Undefined symbol" error on iOS - I'm stumped on: 9 Aug '11 - 16:34
Just tried the update using the example code below. I no longer get the 'BASS_MIDI_StreamEvents' missing symbol error but I only hear one note play (the first one). Shouldn't I be hearing a chord? Tried specifying different channels (out of 16 set up for that stream with same result. Is there still an issue here?

Updated: I notice that with 3 events, as below, I get a single note at volume n. If I specify just one event the volume seems to be n /3. Could there be a bug where the first note in an event array is getting played * array length?

  BASS_MIDI_EVENT events[3];
    events[0].event=MIDI_EVENT_NOTE;
    events[0].param=MAKEWORD(60, 100); // C
    events[0].chan=0;
    events[1].event=MIDI_EVENT_NOTE;
    events[1].param=MAKEWORD(64, 100); // E
    events[1].chan=0;
    events[2].event=MIDI_EVENT_NOTE;
    events[2].param=MAKEWORD(67, 100); // G
    events[2].chan=0;
    BASS_MIDI_StreamEvents(chanIn, BASS_MIDI_EVENTS_STRUCT, events, 3); // process the events
ReplyReply Reply with quoteQuote
Pages: [1] 2
Powered by SMF 1.1.18 | SMF © 2013, Simple Machines