|
About Andrew Choi
MIDI Programs
MIDI File Player (External Device)
MIDI Destination Pop-Up Button
MIDI File Player (Internal Synth)
MusicSequence Sample Code
MIDI File Writer
MIDI Name Document Parser
NameConfigSetup
Fish Creek MIDI Framework
MidnamUtility
SysExSenderX
Other Programs
FCBlogEditor
FCBlog and Patch
Chinese Checkers Program
jyut6 ping3 Cantonese Input Method
Cocoa Sample Programs
Syntax Coloring Using Flex
NSTextField and Undo
NSToolbar
Implementing File Import
Launch Application and Open URL
Saving Uncommitted Text Field Edits
Algorithms
Jazz Chord Analysis as Optimization
Optimal Line Breaking for Music
Optimal Chord Spacing
|
|
|
|
A blog where I will write mostly about programming in Cocoa and CoreMIDI, and experiences from my ports of Emacs and XEmacs to the Mac OS.
|
Printing Page Headers and Footers in Cocoa
|
Friday October 29, 2004
It really isnt difficult to print headers and footers (say to show filenames and page numbers) using Cocoa printing. What makes it difficult is the wrong and useless information in mailing list archives! Just try looking up drawPageBorderWithSize in a search engine.
Heres a sample output with a title in the header and a page number in the footer. Two keys guarantee success:
- The view passed to
printOperationWithView:printInfo: must not be a subview of another view. My first attempt was to pass the documentView of a scroll view; this result in all sorts of unexpected clipping. I ended up creating a separate NSView subclass just for printing.
- Heres how to implement
drawPageBorderWithSize in my NSView subclass (I assume that its isFlipped returns YES):
- (void)drawPageBorderWithSize:(NSSize)borderSize
{
[super drawPageBorderWithSize:borderSize];
NSRect frame = [self frame];
[self setFrame:NSMakeRect(0.0, 0.0, borderSize.width, borderSize.height)];
[self lockFocus];
int page = [[NSPrintOperation currentOperation] currentPage];
NSString *pageNumberString = [NSString stringWithFormat:@"- %d -", page];
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
[attribs setObject:[NSFont systemFontOfSize:10.0] forKey:NSFontAttributeName];
NSSize pageNumberSize = [pageNumberString sizeWithAttributes:attribs];
float bottomMargin = [[[NSPrintOperation currentOperation] printInfo] bottomMargin];
NSPoint pageNumberPoint = NSMakePoint((borderSize.width - pageNumberSize.width) / 2.0,
borderSize.height - (bottomMargin + pageNumberSize.height) / 2.0);
[[NSString stringWithFormat:@"- %d -", page] drawAtPoint:pageNumberPoint
withAttributes:attribs];
[self unlockFocus];
[self setFrame:frame];
}
Thursday October 28, 2004
Implemented a transpose function in the chord editor. Unlike BiaB and MiBAC Jazz, in my design the user can transpose chords in the current selection instead of always transposing entire tunes. Of course the transpose operations are recorded in the undo manager and can be undone and redone.
The implementation uses the jazz theory classes to handle enharmonic chord and note spellings. Correct spellings will therefore be used automatically for the transposed chords and bass notes. Since the chord editor cannot handle chord and note names that are double sharp or double flat, a dialog is displayed to inform the user that a transposition that results in such a chord or note name cannot be performed.
Ive also begun to implement printing. This turns out to be quite easy to do. Heres a PDF file output of one of my test files. I still need to find a way to print the song title and perhaps other useful information. Printing headers and footers seems to be a bit trickier.
On another note, took this picture of a bobcat cub behind my backyard today. I assure you thats not my neighbors domestic cat!
Wednesday October 27, 2004
Added a site search form in the right-hand column below the calendar.
Continued to test my program on BiaB files found on the Web. Among them was one that uses a Cm69 chord, which wasnt recognized by the import routine. Apparently this chord is only supported in newer versions of BiaB (mine is 6.0). Added that to my program. Also fixed a problem with reading BiaB files in 3/4 time.
|
Expressive Performance, Humanization, Groove Quantization
|
Tuesday October 26, 2004
I read a few papers on expressive performance a while ago and I went back today to look at some of them. Itll take quite a bit of effort to incorporate these techniques into my program so I think Ill wait until a later version.
I also played with the groove quantization function in the Opcode Vision MIDI sequencer a little. Although it does liven the sequence, I feel that it might be tiring to listen to sequences modified by the same groove over and over again.
So Ive experimented with small changes to make the output of the accompaniment generation algorithms sound less mechanical. I think some of the more effective modifications may be ones that introduce variations. Heres an accompaniment generated by todays version of my program for the tune Desafinado. The high-hat is now louder on on-beats. Different drum patterns are played in sections A and B. The pattern for section A has two variations. Also, the durations of chords on the piano have been tweaked.
Monday October 25, 2004
Adding bossa nova to the repertoire of styles that the automatic accompaniment program can handle required the addition of a few new instruments to my existing drum kit (rim shot and toms) and a way to disable swing in eighth notes. Implementing the accompaniment generation algorithms for a few styles provides insights into improvements on and streamlining of my jazz theory classes. I wont make these changes now but will save them for version 2, when Ill have a Python plug-in mechanism with which users can implement their own accompaniment generation algorithms.
Anyway heres an example of an accompaniment generated by my program for the tune Desafinado. It sounds mechanical because I havent implemented expressive performance/humanization yet. I hope to work on that in the next few days.
|
Search this blog with
Lists
Less-Known Facts About Emacs
Emacs Rants
Chinese Restaurants in Calgary
Calgary/Banff Tourist Attractions
C++ Reading List
Science Fiction Series
Top-10 Reason I Stopped Working on Emacs
Top-10 Types of Questions I Get About Emacs
10 Defining Moments as Programmer
Misc
Carbon XEmacs
Emacs for
Mac OS X
|