Dulow187 / dsmi

Automatically exported from code.google.com/p/dsmi
0 stars 0 forks source link

libdsmi_iphonelibdsmi_iphone 2 Problems: 81 Messages Only and Can't Instantiate as Global Variable #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm having two problems. I'm using XCode 3.2.3 and coding for iPhone 3.2 and 
4.0 (same problems), both the simulator and the device.  Dev machine runs OSX 
10.6.4.

I am using DSMI by just grabbing the libdsmi_iphone.m and the libdsmi_iphone.h 
and including them in the project. For good luck, I also include the CFNetwork 
framework.

PROBLEM 1
Can't use libdsmi_iphone as an instance variable (I'm using a nonatomic retain 
property) in a UIViewController. If I use this code in my viewDidLoad method, 
it fires and retains the libdsmi (I should release after, but I don't for this 
test):

    self.libdsmi = [[libdsmi_iphone alloc] init];

then this code, in a slider-move method

    [self.libdsmi writeMIDIMessage:MIDI_CC MIDIChannel:0 withData1:1 withData2:counter++];  

does nothing. This would all be irrelevant, except  that this works in the 
onChange method

    libdsmi_iphone *midiLib = [[libdsmi_iphone alloc] init];
    [midiLib writeMIDIMessage:MIDI_CC MIDIChannel:0 withData1:1 withData2:counter++];   
    [midiLib release];

Not sure what this might be about. If I initialize an NSString in the same 
place, it gets read just fine in the onChange method (so it's not a basic 
coding/conceptual error).

PROBLEM 2
I am only able to send 82 messages. This is strange as can be:

    libdsmi_iphone *midiLib = [[libdsmi_iphone alloc] init];
    [midiLib writeMIDIMessage:MIDI_CC MIDIChannel:0 withData1:1 withData2:counter++];   
    [midiLib release];

Counter gets to 81 and then I receive no more on the server-side. it's not the 
value of counter, because I can send up to 127 with no problems.

Perhaps I need to set some delegates or something so a buffer somewhere can 
drain...?

Thanks and thanks for your help and this great library!

Original issue reported on code.google.com by dr2...@gmail.com on 7 Sep 2010 at 2:16

GoogleCodeExporter commented 9 years ago
Both problems happen on both the iPhone simulator (4.0 and 3.2) and the device 
(4.0 only, iPod Touch).

Original comment by dr2...@gmail.com on 7 Sep 2010 at 2:18

GoogleCodeExporter commented 9 years ago
I think you may have an issue with how you are using the library.

If you are running

    libdsmi_iphone *midiLib = [[libdsmi_iphone alloc] init];
    [midiLib writeMIDIMessage:MIDI_CC MIDIChannel:0 withData1:1 withData2:counter++];   
    [midiLib release];

Within a loop, this is going to cause problems. You should only be 
instantiating this class once, or at least only once every time you want to 
restart a connection.

    libdsmi_iphone *midiLib = [[libdsmi_iphone alloc] init];
for (int counter = 0; counter < 200; counter++) {
    [midiLib writeMIDIMessage:MIDI_CC MIDIChannel:0 withData1:1 withData2:counter]; 
}
    [midiLib release];

should work

Original comment by parknat...@gmail.com on 29 Oct 2010 at 6:32