October 23, 2007

The Toys of Summer have gone

We are proud to say that the "Toys of Summer have gone" gone back to our website! Booyah! Check it out: TOYS!

Yeah, ain't that sweet? I think it is. I don't care if I really butchered (like Jared) that Don Henley song title just for a blog post. I'd do it again if you let me.

Also, check out the holiday goodies, on the Toy's page under Goodies (tricky I know). We've got a wicked (both in the traditional and Boston sense) wallpaper (or Desktop) featuring the ever lovely Jen and Monty all decked out for Halloween. Click this link to check it out. Maybe if I can sober Steve up I'll get other works of art out of him. Until then, PEACE!

Posted by Bruce at 03:43 PM | Comments (0)

August 21, 2007

NSPartyFridge

We wouldn't normally break our Mac OS X Leopard NDAs for any reason, but when we saw a new class in the Leopard ADC documentation earlier tonight, we knew the world had to be informed.

Check out the newest amazing class from Apple.

Posted by mikey at 12:18 AM | Comments (1)

March 15, 2007

New Everything: Using AppleScript with Sound Studio 3

Today's monkeybloggery comes from a post I made recently on our forums.

One of our (awesome) users wanted to know if Sound Studio 3 had a command to create a new document from the current selection. While Sound Studio can't do it directly, I knew it could be done with a quick bit of AppleScripting, so I jumped in and posted a script I'd written previously to accomplish the task. (The real power of AppleScript is making smart applications do things they can't normally do, after all.)

I took a second look at my old script this morning, the one I posted, and realized it needed some improvements to bring it up to normal standards. I'd like to walk our readers through writing the script, to demonstrate a little bit of how to work with Sound Studio via AppleScript.

Slow Moves

Diving straight past the run and application tell lines:

  1. on run
  2. tell application "Sound Studio"
  3. if ((count of windows) > 0) then
  4. set sourceDocument to window 1

In the first highlighted line, we want to make sure that Sound Studio actually has at least one document open before executing the rest of the script. By doing this, we eliminate "undefined" behaviour as well as avoid running the rest of the script, in the event there's nothing to do.

In the second line, we're going to create a reference to the frontmost window—the one we're going to be copying the selection from—so we can use it later without needing to know what order our windows are in before we use them. The idea is that a random keystroke, mouse click, or even another script could change the order of Sound Studio's windows, and we don't want to have to worry about that causing problems.

Doing this also has the benefit of making your script more readable, and that's always a plus.

  1. on run
  2. tell application "Sound Studio"
  3. if ((count of windows) > 0) then
  4. set sourceDocument to window 1
  5.  
  6. set startTime to start time of selection of sourceDocument
  7. set stopTime to stop time of selection of sourceDocument

Another way to make the script smarter is to make sure that there is audio selected in the current document. We'll start by recording the values of the beginning and end of the current selection. If there is no selection, we'll get back the location of the blinking cursor for both values.

  1. on run
  2. tell application "Sound Studio"
  3. if ((count of windows) > 0) then
  4. set sourceDocument to window 1
  5.  
  6. set startTime to start time of selection of sourceDocument
  7. set stopTime to stop time of selection of sourceDocument
  8.  
  9. if (startTime ≠ stopTime) then
  10. [...]
  11. end if

If they don't match, our selection is greater than 0 seconds. (That is, there actually is a selection with which to create a new document!) Now we're ready to do some work.

  1. on run
  2. tell application "Sound Studio"
  3. if ((count of windows) > 0) then
  4. set sourceDocument to window 1
  5.  
  6. set startTime to start time of selection of sourceDocument
  7. set stopTime to stop time of selection of sourceDocument
  8.  
  9. if (startTime ≠ stopTime) then
  10. -- The script uses the clipboard, so make sure we record the current contents of the clipboard.
  11. set previousClipboardContents to the clipboard
  12.  
  13. copy selection of sourceDocument
  14. [...]
  15. end if

To bounce audio back and forth between Sound Studio documents using AppleScript, you need to use the clipboard. However, this presents us with a problem, because once you copy audio data to the clipboard, whatever was there before will be lost forever. Now, realistically, a user should never have "volatile" (that is, non-replaceable) data on the clipboard, but it happens. Furthermore, since there's no indication of what's going on in the background, it's potentially confusing and frustrating for the user if suddenly what he thought was there is nowhere to be found.

To circumvent this problem, we need to record the current state of the clipboard before we start bouncing audio. When we're done, we'll put things back where we found them. You'll see this part later.

After we've recorded the state of the clipboard for future use, we're safe to copy the current selection of audio to the clipboard.

  1. on run
  2. tell application "Sound Studio"
  3. if ((count of windows) > 0) then
  4. set sourceDocument to window 1
  5.  
  6. set startTime to start time of selection of sourceDocument
  7. set stopTime to stop time of selection of sourceDocument
  8.  
  9. if (startTime ≠ stopTime) then
  10. -- The script uses the clipboard, so make sure we record the current contents of the clipboard.
  11. set previousClipboardContents to the clipboard
  12.  
  13. copy selection of sourceDocument
  14. make new document
  15. set newDocument to window 1
  16. [...]
  17. end if

This part is pretty straightforward. Now that we've got our selection on the clipboard, we need to create a new document window and then make a reference to it, like we did with our sourceDocument reference.

Okay, now here's the fun part:

  1. on run
  2. tell application "Sound Studio"
  3. if ((count of windows) > 0) then
  4. set sourceDocument to window 1
  5.  
  6. set startTime to start time of selection of sourceDocument
  7. set stopTime to stop time of selection of sourceDocument
  8.  
  9. if (startTime ≠ stopTime) then
  10. -- The script uses the clipboard, so make sure we record the current contents of the clipboard.
  11. set previousClipboardContents to the clipboard
  12.  
  13. copy selection of sourceDocument
  14. make new document
  15. set newDocument to window 1
  16. paste selection of newDocument existing 0 pasteboard 0 inside no
  17. [...]
  18. end if

There are four things going on in this line:

paste selection of newDocument: The actual paste selection command is a bit strangely worded, in that it doesn't mean "paste the current selection somewhere". Instead, this part's saying, "Paste into the current selection of newDocument."

existing 0: Sound Studio has the ability to mix intelligently what you're about to paste with what's already there. Measured in floating point decibels, the existing value determines what adjustment to make to the section you're about to paste into.

pasteboard 0: Measured in floating point decibels, the pasteboard value determined what adjustment to make to the audio being pasted into the current selection from the clipboard.

inside no: Passing no here tells Sound Studio that you don't want the length of the audio you're pasting to be limited by the length of the selection into which it's being pasted.

  1. on run
  2. tell application "Sound Studio"
  3. if ((count of windows) > 0) then
  4. set sourceDocument to window 1
  5.  
  6. set startTime to start time of selection of sourceDocument
  7. set stopTime to stop time of selection of sourceDocument
  8.  
  9. if (startTime ≠ stopTime) then
  10. -- The script uses the clipboard, so make sure we record the current contents of the clipboard.
  11. set previousClipboardContents to the clipboard
  12.  
  13. copy selection of sourceDocument
  14. make new document
  15. set newDocument to window 1
  16. paste selection of newDocument existing 0 pasteboard 0 inside no
  17.  
  18. -- Restore the user's clipboard to its previous state.
  19. set the clipboard to previousClipboardContents
  20. end if
  21. end if
  22. end tell
  23. end run

Now all we need to do is restore the contents of the clipboard we saved earlier. Close our statements, and we're done.

The Salmon Sounds Good, but What Else Is on the Menu?

Now we just need a convenient way to run the script. Luckily, Apple's solved this one for us. Here's info on how to enable and use the Script Menu in Mac OS X:

http://www.apple.com/applescript/scriptmenu/

A copy of the script can be downloaded here:

New Document with Selection

Posted by mikey at 01:47 PM | Comments (0)

December 21, 2006

Lasing Around

So, Phil Torrone (of Make Magazine fame) teamed up with Limor Fried to start an open-source-business-model laser etching service in downtown NYC, Adafruit Industries Laser Services.

The victim? My MacBook!


The Epilog laser etcher. I want one.


After making an appointment with Phil and sending him my artwork, I headed on down to Jones St. Phil tweaked the art on his MacBook Pro before moving it over to a PC connected to an Epilog laser etching machine. The Epilog is capable of etching up to 1200dpi, so your artwork can be extremely detailed and will be etched precisely.


Measure twice, lase once. That's the last use of the word "lase," I promise.


The vector art on a PC hooked to the Epilog.

Before etching my MacBook, we made a paper proof - lowering the laser's power allows it to "write" onto standard copy paper, so that we could check the alignment of the design before forever etching the art into the MacBook.


Lining up the 'Book.


Prepping to make a paper proof.

And I got to press the green GO button. It was awesome!


Here goes!


No turning back now - as the laser flies back and forth, the design starts to take shape.


Almost done...


The final product. Shnazzy.

Posted by Justin at 09:47 PM | Comments (1)

April 17, 2006

The Way You Found Me

If anyone ever tells you that making video games is an easy job, take heed at what it can do to a man. Heed.

Miller Time.

Bruce is still under there, actually—we're not sure if he's breathing. Anyone got a mirror?

Posted by mikey at 11:37 AM | Comments (0)

April 06, 2006

There's a Story in Your Voice

So guess who stopped by to record some WingNuts 2 audio?

Jen speaks!

Posted by mikey at 05:36 PM | Comments (3)