About this Blog

fGroove is a audio loop player that allows multiple people to select audio loops that will play in time and at the correct tempo. Think of it as a multitouch version of a groove matrix. Note, I'm just learning to program the surface. While code examples here should work, they may not be the "correct" or "official" way of doing things

Thursday, December 17, 2009

Adding a Library Stack

The next job was to add a library stack. The idea is that ScatterViewItem's (with the audio loop attached ) can be drag and dropped into a LibraryStack and will then be grouped together. Tappping on the Library stack will make all loops in the stack play together. This didn't sound too hard but I've found it harder than expected.

First job, get an example program working. In the Surface SDK help files there is a programmers guide, with a section "Using the Drag and Drop Framework" with a section "Dragging and Dropping Items from ScatterView Controls to SurfaceListBox Controls". Changing this to drag and drop to a Library Stack was quite easy. Integrating it with my current program was hard. First problem, the example program use ObservableCollections to bind to the Scatterview and LibraryStack in the XAML. The easiest thing to do was change my original program to follow this pattern.

Second problem is that Example program uses the PreviewContactDown event to begin the drag and drop operation. Thats the same event that the current program uses for tap handling. Look at this video and you'll see that the tap event only happens some of the time. The easy fix was to use a PreviewContactHoldgesture to begin the drag-drop action. It's a bit of usability scutter but seems to work.

The current problem is that although loops play in the LibraryStack, if you add a loop while the stack is playing, it plays when the stack is stopped. The solution hopefully is to add code that checks to see if the stack is playing when the drag is finished and add that loop to the playlist. This should be the SurfaceDragDrop Drop handler. Except it doesn't seem to get activated in the current program. Ho Hum.....

And a quick test with the original Drag Drop code seems to suggest that a LibraryStack does not generate a onDrop Event, but changing it to a PreviewDropHandler does trigger the event. Looks solved now.

No comments:

Post a Comment