Google
www ResExcellence

Application Makeovers
Desktop Snapshots
iTunes Skins
Mighty Mouse Cursors
Uploads
Boot Images
Dock Poofs
Links List
Photoshop Goodies
Users Forum
Boot Panels
Download Stats
Log-In Panels
REALbasic
Clocks
GUI Software
Mac OS X Mods
Safari Stuff
Desktop Pictures
Icons
Mac OS X Themes
Splash Screens
Homepage
Download a free demo of REALbasic!
Download a free demo of REALbasic!
Recent Articles...
3D
3D Photo Gallery (Part 2)
3D Photo Gallery (Part 1)

Audio
iPod Tricks (Part 3)
iPod Tricks (Part 2)
iPod Tricks (Part 1)
Laugh Track Machine
Audio Player with Reverb
Shepard Melody
RB Phone Home
Build a Drum Machine

Custom Controls
Custom Buttons
Custom Buttons Part II
iTunes-style Listboxes
Custom Controls

General RB
Wiggle Window
JPEG in PDF
Hey! You got your Checkbox in my Listbox!
Background Applications
Listbox Auto-Find
Virtual Volumes
Time Tracker
Software Distribution (Part 4)
Software Distribution (Part 3)
Software Distribution (Part 2)
Software Distribution (Part 1)
Exceptions
Living on the Edge
Tips and Tricks
Review of REALbasic 3.0
Text Clippings Made Easy

Graphics
Image Spinner
Cropping Graphics (Part 4)
Cropping Graphics (Part 3)
Cropping Graphics (Part 2)
Cropping Graphics (Part 1)
Shimmer Graphics
Lissajous Figures
Simple Screen Capture
Vector Graphics
Kaleidoscope Images
Stegonography
Spirals!
Image Table
RB Magnifying Lens
Screen Capture
Color Picker Tutorial

Hacks
Ghost Grab
Speedy Mouse Extension
iTunes Plugins
iTunes Skinner

Internet
Display Web Image In Canvas
HTML IMG Tags
Version Tracking
Even Smarter Instant Messaging
Web Tiler
JavaScript and REALbasic
Stock Ticker (Part 2)
Stock Ticker (Part I)
AIM Mate

Mac OS X
Using Sheets in REALbasic
Build a Bundle (Part 2)
Build a Bundle (Part 1)
Dock Your Passwords
Mac OS X Debugging
REALbasic Mac OS X Icon Tutorial
Animate Your Dock
RB and the Command Line

Novelty
Guessing Game
Calendar Trivia
Tile Mixer
Zip Code Finder
Happy Valentine's Day
Merlin Simulator (Part 3)
Merlin Simulator (Part 2)
Merlin Simulator (Part 1)
Buzzword Machine
AppleSoft BASIC

Printing
Print to PDF

Registration
Registration Code Validation
Network Registration Codes

Resources
Picture Extractor (Part 2)
Picture Extractor (Part 1)

Serial
Caller ID (Part 3)
Caller ID (Part 2)
Caller ID (Part 1)

Speech
Speech Recognition

Video
Big Brother Video Capture

Newest Dev Tools!




Book Alert !
REALbasic for Dummies
by Erick Tejkowski
$19.99 @ Amazon

Made with REALbasic!

Problems?
Downloads are in StuffIt 5 format (free download).
Tell me about a bad link (Thanks!).
Submission Policy

10-04-01

Build a REALbasic Drum Machine by Erick Tejkowsi

This week we'll create a fun little project that mimics a drum machine. This project is somewhat unique in that it uses high quality samples for the drum loops, lets you start and stop the loops at will, and yet the whole thing only requires two lines of code! How are we going to pull this one off? Read on!

Introduction

The secret behind this week's project involves two file formats : SoundFont(.sf2) and Downloadable Sounds(.dls). These two file types are capable of storing multiple audio samples in one file. Think of them as audio packages. All audio samples are located conveniently in one file. These samples might represent a variety of sounds: orchestral instruments, pop vocals, car horns, or dog barks.

To hear the sounds within SF2 and DLS files, you can trigger them with MIDI from REALbasic. QuickTime added SF2 and DLS support beginning with QuickTime 5 and REALbasic works great in combination with it. (For best results on this project, download the latest version of QuickTime.) To install a SF2 or DLS file, drag it into one of the following folders on your hard drive:

  • For Mac OS 8/9 - Hard Drive:System Folder:Extensions Folder: QuickTime Extensions
  • For Mac OS X - Home:Library:Audio:Sounds:Banks

In case you don't have any SF2 or DLS files, some are included with the project download at the end of this tutorial. There are also many free files in SF2 and DLS format. SF2 has been fairly popular in the Windows world for several years, so you will find many of this file type on the web. DLS is a somewhat newer format, so it hasn't gained as much momentum yet. Files in this format are harder to find right now. DLS, however, is now the de facto standard (it's part of the MPEG4 spec., for example), so expect to see more it in the future. At the end of this tutorial are some links, where you can find sounds or learn to build them yourself.

Once you have moved your SF2 and DLS files to the proper location on your hard drive, open the QuickTime Control Panel (Mac OS 9) or the QuickTime Panel of the System Preferences (Mac OS X). Select your file and press "Make Default" for Mac OS X. For Mac OS 9, simply click the little black circle to the left of the sound bank's name.

10-04_osxqt.jpg (26k)

10-04_qtsettings.jpg (26k)

After you select a sound bank, close the QuickTime settings and launch REALbasic.

Build an Interface and Add the Code

To begin building the interface, double click Window1 in the Project Window. Drag four NotePlayers and eight PushButton controls from the Toolbar to your interface. Name them according to this chart:

Control Settings Number of Controls With This Name
NotePlayer Name : NotePlayer1
Give each NotePlayer a unique Index number starting at 0 (zero). Give each NotePlayer a unique Instrument number starting at 1
4
PushButton Name : PlayButton
Give each PlayButton a unique Index number starting at 0 (zero)
4
PushButton Name : StopButton
Give each StopButton a unique Index number starting at 0 (zero)
4

Notice above that we are using control arrays. In other words, 4 buttons share the same name (PlayButton, for example), but each has its own unique Index number. This permits you to write code one time and let each control with the same name use that code. The NotePlayer Instrument number normally corresponds to a General MIDI Instrument as listed in the RB Language Reference. It needn't, however. When a SF2 or DLS file is used as the QuickTime music engine, the instruments are numbered according to the order they appear in the file. The demo files included with this project have four "instruments" per file.

10-04_playbutton.jpg (18k)

10-04_stopbutton.jpg (17k)

The completed interface might look something like this:

10-04_interface.jpg (18k)

The final step is to add the two lines of code. Double click any one of the PlayButtons and enter this line:

NotePlayer1(Index).PlayNote(60,127)

This simple line of code starts up the NotePlayer control that shares the same Index number as this PushButton. It plays MIDI note number 60 at a volume of 127 (volume = 0-127). The second line of code is equally small - it turns off the note, by sending it a volume fo zero. Place this code in the Action event of the StopButton

NotePlayer1(Index).PlayNote(60,0)

Conclusion

That's it! Test your project by selecting Debug->Run. If all is working well, you should hear some unique sounds coming out of QuickTime, instead of those boring old QT Instruments you're used to. Feel free to download some other SoundFont or DLS files and activate them the same way. Your project can then instantly make use of the new sounds.

If you're too lazy to build this week's project, there may be no hope for you. :-) We still have the project available for download, though. It also contains a few sound banks for your listening enjoyment. You can learn more about SoundFont and DLS at the following URLs:

BEST Software Design - Creators of PolyPhontics, the forthcoming Macintosh SoundFont and DLS Editor.

Creative Technologies - Co-inventors of the SF2 format. Creators of the Mac-compatible SoundBlaster card.

SynthZone - A huge listing of SoundFont and DLS sites.

Sonic Implants - Sells commerical SoundFont and DLS samples. They also hand out some great freebies too.

HammerSound - Another large collection of SoundFont files.

Have fun and see you next week!


10-2-01

REALbasic News by Erick Tejkowsi

Aqua Aware Menus Paul Mitchum has posted a unique code example, called AquaAwareMenuItem v.1.0

AquaAwareMenuItem is a MenuItem subclass that splits the EnableMenu event into two new events: the EnableMenu event and the AquaEnableMenu event. AquaEnableMenu is triggered if the application is running under Aqua; EnableMenu is triggered otherwise.

Stimulating! Electric Butterfly has released a new applicatin called Stimulus 1.0. It's a nifty multimedia viewer, but more importantly, it was "Made with REALbasic" (MWRB). Check it out!

New Tip! Need to write to the console in Mac OS X? The REALbasic Tips list has a nice example for you to try:

Sub WriteDebugMessage(msg as String)
  dim msgBlock as MemoryBlock
 Declare Sub DebugStr Lib "CarbonLib" (msg as Ptr)

 msgBlock = NewMemoryBlock(256)
 msgBlock.PString(0) = Left(msg, 255)
 DebugStr msgBlock
End Sub
What?!?! You're not on the Tips List? Subscribe here.

Crazy Code. REALbasic genius, Matthijs van Duin, has temporarily updated his web site to make things easier to find. He promises to make it prettier in the future, but for now this is an excellent site for RB Pros and Newbies alike.

Transfer Those Files! Alfred Van Hoek has updated his QuickTime File Transfer plugin again. This sucker will even do multiple simultaneous downloads, so it's a must-have.

Play With Your Pictures. Picture Play is an application for creating compositions of many images. It is basically an electronic collage. You can use it to incorporate multiple images into a single artistic image, and add text labels as well. Oh, and it too is "Made With REALbasic".


Application Makeovers
Desktop Snapshots
iTunes Skins
Mighty Mouse Cursors
Uploads
Boot Images
Dock Poofs
Links List
Photoshop Goodies
Users Forum
Boot Panels
Download Stats
Log-In Panels
REALbasic
Clocks
GUI Software
Mac OS X Mods
Safari Stuff
Desktop Pictures
Icons
Mac OS X Themes
Splash Screens
Homepage

Maintained by the Staff of ResExcellence. This entire site ©1997-2003 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement.

[an error occurred while processing this directive]on the ResEx LinuxPPC Server