Archive

Archive for the ‘Developer’ Category

Configuring EZDrummer note names in Ableton Live

January 10th, 2010 1 comment

I do my “serious” recording using Cakewalk Sonar, but I write most of my songs in Ableton Live. I find it really easy to work out parts and figure out arrangements in Live, even if it’s a tool more associated with loop based dance music and DJing than songwriting.

Live includes a nice set of rhythm instruments, but I tend to use Toontrack EZDrummer for my actual drums sounds. The two work well together, except for the fact that there’s no automatic way AFAICT to have the Live piano roll show names like “Kick” or “Snare Left” instead of “C1” and “A0”. To do that, you need to create a Midi Effect Rack with a chain for each note. It’s easy enough to do, but why should every person who wants to do that have to waste time re-entering this data?

Here’s an Ableton Live Instrument Rack for EZDrummer. There, I just saved you 15 minutes of mindless data entry.

 

image

Cool, I’m a Java programmer…

November 16th, 2009 No comments

…or at least I finished the Eclipse and Java for Total Beginners lesson. I’m going to write some apps for my new Motorola Droid (*swoon*), so I figured it was best if I ran through something that would help me get comfortable with the new IDE and Java syntax. The tutorial was pretty slow for someone with decent OO programming skills, but I definitely feel much more comfortable with Eclipse after having worked through the tutorial. I’m especially fond of the integration of JUnit and the ease of TDD with Eclipse.

Expect my first Android app soon!

Categories: Developer Tags:

CabSdk Update, ClrSpy Love and geek teamwork!

September 1st, 2006 No comments

 

As I mentioned previously, my team needed a managed wrapper around the CAB APIs in order to extract and test the contents our InfoPath templates programmatically*. We found a great series of articles on the subject by Jim Mischel, downloaded the sample code, and set to building our automated testing tool. Unfortunately, we ran into a snag once we began trying to decompress multiple XSN files. Luckily Adam Nathan’s CLRSpy came to the rescue. Here’s how I debugged the problem.

When our app got to the point of processing the third or fourth CAB, an Exception was thrown:

System.NullReferenceException: Object reference not set to an instance of an obj
ect.
at CabDotNet.CabSdk.FdiDestroy(IntPtr hfdi)
at CabWrapper.CabDecompressor.Dispose(Boolean disposing)
at CabWrapper.CabDecompressor.Dispose()
at CreateTemplatesAndViewers.testfdi.ExtractFiles(String cabinetFullPath, Str
ing destinationDirectory) in d:\visual studio projects\utilities\createtemplates
andviewers\testfdi.cs:line 70

Not knowing what the problem was, I dug through the source code looking for obvious managed code problems. Nada. At that point I started to suspect the interop portion of the code, so I fired up CLRSPy and ran the app again. Bingo! I saw the following in the CLRSPy log:

Collected Delegate in XSNInjector.exe (PID 5976): Unmanaged callback to garbage collected delegate: CabDotNet.FdiFileReadDelegate

Aha! The managed delegates Jim was creating were being Garbage Collected before the umanaged CAB API tried to call them. But why? Looking at the CabSdk.FdiCreate wrapper function, I noticed the call to the actual unmanaged FdiCreate function:

hfdi = CabSdk.FdiCreate(
new FdiMemAllocDelegate(MemAlloc),
new FdiMemFreeDelegate(MemFree),
new FdiFileOpenDelegate(FileOpen),
new FdiFileReadDelegate(FileRead),
new FdiFileWriteDelegate(FileWrite),
new FdiFileCloseDelegate(FileClose),
new FdiFileSeekDelegate(FileSeek),
erf);

The delegates being created (“new FdiMemAllocDelegate(MemAlloc)”, etc.) weren’t being refered to at all in the managed code! The GC doesn’t track unmanaged references to managed objects, so it felt free to collect them once there was enough memory pressure. The fix was relatively simple, I just created member variables to hold references to the delegates and our app was able to process any number of CABs without any problems.

Jim has since posted an updated article and code:

After the third article was published, I began receiving reports of intermittent unexplained failures of the CabCompressor and CabDecompressor classes when compressing and decompressing cabinet files. After much investigation, reader Gerrard Lindsay sent me the solution.

Ah, teamwork!

 

 

Categories: Developer Tags:

My first time with CLR in the DB

August 5th, 2005 No comments

Well, after a pretty interesting session on CLR integration in SQL Server 2005 I was desparate to actually start writing some code.
We were lucky enough to get the opportunity to visit the Experience Music Project tonight (more on that later), but as soon as I returned to my suite I sat down at the old Tablet and got cracking.

Unfortunately, it took me nearly an hour to get SQL up and running on my new Vista build. I tried running the installation a few times, but kept getting an error:

Shared Memory Provider: Connection was terminated [1236].

I stumbled onto a possible fix, but still no dice. Then I remembered that I haven’t had an opportunity to join our domain (more software problems ;) )…I had configured the MSSQL service to run as system, so I tried switching it to run w/ a local account on a lark and things fell swiftly into place.

The next step was creating a database, a sample table, and then a VS.NET database project. Twenty minutes later I had a working user defined function to strip host names out of email addresses. Even better, the debugging worked perfectly and helped me catch a little sleepiness induced bug in my code.

Here’s my managed UDF:

     [Microsoft.SqlServer.Server.SqlFunction]     public static SqlString GetHostNameFromEmail(SqlString rawEmailAddress)     {         string rawEmailAddressAsManagedString = rawEmailAddress.ToString();                  int startIndex = rawEmailAddressAsManagedString.IndexOf('@');         int endIndex = rawEmailAddressAsManagedString.IndexOf('.', startIndex);          string result = null;                  if (startIndex > -1 && endIndex > -1)         {             result = rawEmailAddressAsManagedString.Substring(startIndex + 1, endIndex - startIndex -1);         }          return new SqlString(result);     }  

and the query I used in the test script which triggers the function when I start debugging:

 SELECT dbo.GetHostNameFromEmail(EmailAddress) FROM dbo.Customer 

Sweet. It's going to be hard to go back to work, VS.NET 2K3 and Oracle. It won't be hard going back to my own apartment...next stop NYC! [updated 8/5: I added the code samples.]

Categories: Developer Tags:

XmlPreCompiler: The tool Scott Hanselman forgot

June 30th, 2005 No comments

Scott Hanselman recently published the 2005 edition of his Ultimate Developer Tool List, which is a great resource for (especially Microsoft) developers. I’ve found links to a bunch of great tools I hadn’t heard about.

I was surprised at the omission of the XmlPreCompiler from the list, though. It’s not a tool that I use very often, but when I have an XML Serialization problem it’s my best ally.


Have you ever run into an exception like:

Error: System.IO.FileNotFoundException: File or assembly name k5gfdivf.dll, or one of its dependencies, was not found.

Which makes you think, “what the heck? I never created any assembly called ‘k5gfdivf’, and I think I would have remembered adding a reference to it.” Don’t worry, you’re not getting forgetful.

When you create the first instance of XmlSerializer for a type the framework dynamically generates custom C# code to map between object<->XML representations of the type. This assembly does the actual work of serializing and deserializing instances of the type. If for some reason the type to be serialized cannot be serialized correctly, the dynamically generated code may contain compilation errors. When the framework goes looking for the compiled assembly, named something like “k5gfdivf” for instance, it doesn’t find it and you get the FileNotFoundException you see above.

Microsoft has released a KB article with instructions on finding compiler errors in the code that XmlSerializer generates, but it requires some manual work. That’s where the XmlPreCompiler (or the original command line version from Chris Sells) comes into play. Run the app, select the assembly in question, and you’ll get a messagebox including the exact compilation error being encountered.

I’d rate it a must have! Maybe it will make the list in 2006?

Categories: Developer Tags:

Atlas Project…man, I can't wait

June 29th, 2005 No comments

ScottGu posts about ATLAS, the upcoming AJAX framework from the ASP.NET team:

The popularity of AJAX shows the growing demand for richer user experiences over the web. However, developing and debugging AJAX-style web applications is a very difficult task today. To write a rich web UI, you have to know a great deal of DHTML and JavaScript, and have a strong understanding of all the differences and design details of various browsers. There are very few tools to help your design or build these applications easily. Finally, debugging and testing these applications can be very tricky.

If you’ve paid attention to my GotDotNet submissions you’ll already know how much I enjoy using server side code to generate client side functionality via clientside script. I anticipate a lot of fun applications coming your way from the pickabar factory!

Now when do we get a beta drop?


Categories: Developer Tags:

Convert literals to expressions

March 23rd, 2005 No comments

There’s just something fun about writing server side code, which in turn writes out client side script. I don’t know why, but it’s one of the tasks that brings me back to the magical feeling I felt the first time I saw the characters “Hello World” print out on a console.

The only part that isn’t fun is converting a complex script into a C# or VB.NET string expression. A little while back I wrote a web form to convert literals (incuding scripts) into expressions. I just posted the bits for the ConvertLiteralToExpression Library to GotDotNet in case you want to expand on it, or run your own.

I originally planned on writing this code as an excuse to learn about .NET’s CodeDom mechanism for dynamically generating code. However, when the quick mockup using string manipulation became part of my main toolkit, I lost interest.

Once I’ve ramped up a bit on Whidbey I may convert this to a VS.NET add-in…


Categories: Developer Tags:

Using the DictionarySectionHandler for a custom configuration section

December 1st, 2004 No comments

I needed to create a custom name/value pair .NET configuration section in my application’s configuration file, and was delighted to find the Custom Element for NameValueSectionHandler and DictionarySectionHandler page in the .NET docs. Unfortunately, I couldn’t get their sample configuration file to work. Here’ what does seem to work…


The example in the docs shows:

&#60;section name=”dictionarySample”
type=”System.Configuration.DictionarySectionHandler,System”/>

However, I’ve only been able to get it to work using the full name (including the…) like so:

&#60;section name=”inspectionTypes”
type=”System.Configuration.DictionarySectionHandler, System, Version=1.0.5000.0, Culture=neutral,PublicKeyToken=b77a5c561934e089″/>

Categories: Developer Tags:

Bellydancin' on ASP.NET

November 5th, 2004 No comments

Sarah just posted about Habibi, a belly dance blog that her teacher Amar writes for. I took a look at their site on a lark, and they’re running DotNetNuke on ASP.NET. Nice ;) .


Categories: Developer Tags:

Addy Santo Rocks!

November 3rd, 2004 No comments

For the second time in the last month I’ve bumped into a problem, googled it, clicked on a link to Addy’s blog, and found the perfect solution.

There are lots of .NET blogs that cover the esoterics of CLR internals, v-next versions of the tools, and geek chic stuff that is very interesting but not all that useful for shipping apps. Then there are the blogs that contain practical information and insights that make you more productive writing code day to day. The first category of blogs are fun, but the I’d be less able to get things done without the latter group.

Thanks Addy!


Categories: Developer Tags: