Whimsical In The Grain Pan

2012-11-02: The update, Grain Science 1.3.5, is now released; this should resolve the issues mentioned below. If you run into issues with Grain Science, and you’ve checked you’re running the latest version, please let us know and we’ll check into it for you.

So, iOS 6 was recently released, along with the iPhone 5, and we promptly issued updates for our apps where needed. With one exception: the app we didn’t immediately release an update for is Grain Science. This is because we ran into some last-minute issues and had to pull the update until we could address them.

That’s now been done, the update is with Apple waiting for their approval, and hopefully it will be in your hands soon (2012-11-02: it now is!). While, as with any update, there are a number of improvements and fixes, there are two main issues you might have encountered using Grain Science 1.3.4 under iOS 6:

  • Background Audio may fail to work
  • When listening with headphones/speakers, sound may only come out of one speaker

These are both resolved in version 1.3.5.

Background Audio

Somewhere around iOS 5.1, Apple made a change that caused Background Audio to stop working for apps that need to record, as well as play, audio. It would appear to work at first: if you returned to the Home Screen, audio would keep playing. When you switched to another audio app — which is usually the point of enabling Background Audio, you want to use two audio apps together — you would be disappointed, as the first app would be silenced the moment the second app requested access to the audio hardware.

The workaround added to Grain Science was to detect when you switch away from it, and change its mode from “play and record audio” to “only play audio” (it would switch back when you returned to the app). This was fine because Grain Science’s recording facility allows you to record audio into the Grain Units (to use as the basis of new instruments), but you don’t do this in the background, only while the it is the primary app.

It seems that in iOS 6, Apple have changed their minds, and play-and-record apps can now once again play in the background. In the process though, somehow they broke Grain Science’s background audio workaround. We haven’t investigated the reasons in detail, since the workaround is no longer necessary, so now we just don’t perform the switchover if we detect iOS 6.

Panning and Reverb

In iOS 6, there seems to be a bug in the 3D Mixer. The 3D Mixer is an iOS 6 component that takes multiple sources of audio, positions them (like panning from left to right in stereo, but potentially more sophisticated — it can do up/down/forwards/backwards as well), and mixes the result down into a single audio stream. It can also apply reverb FX, and we make use of this in Grain Science. Mostly, when you play with Grain Science’s Position & Reverb panel, you’re sending commands to the 3D Mixer.

Unfortunately, in iOS 6, if the 3D Mixer’s reverb is enabled, then the stereo output is broken, such that all “dry”footnote 1 sound comes out of one speaker only, regardless of where you set the pan control.

We’ve reported the bug to Apple — along with sample code and other information to help track down the issue — and hope that they will fix it in a future iOS update. But those updates tend not to come out very frequently, and we needed to fix Grain Science for our users in the meantime. So.

I put Wooji Juice’s other work on hold to address this issue. It’s frustrating, because this broke for reasons out of our control and it would be preferable to invest that time in new products or new features for existing products, instead of working around iOS bugs. But we try to do right by our existing customers if there is a way; nearly all of Grain Science’s instruments use at least a little bit of reverb to give them “body”, so this problem is quite wide-ranging.

Since the bug only appears when the 3D Mixer’s reverb is enabled, what I decided to do in the end, is turn off the 3D Mixer’s reverb, take the “positioned” output of the 3D Mixer, and feed it into a replacement reverb effect.

This isn’t a perfect solution: the reverb settings (eg Cathedral, Large Hall) used by the 3D Mixer aren’t known, so the new reverb will not sound exactly the same as the original. This may change the sounds of your instruments slightly, something we hate to do. But it seems that we have no choice.

However, on the upside, the alternate reverb is more controllable. As well as a set of presets that match (as closely as we can manage using guesswork) the 3D Mixer presets, there’s an additional mode: Custom. If you select Custom Reverb mode, you can directly control the early reflection echo delay times and long-tail decay times. You have control over how long the reverb lasts for (up to 20 seconds!) adjusted separately for high and low frequency sound, to simulate absorption properties of different materials, and you can “focus” the reverb into sharply-defined echoes, dense overlapping reverberation, or somewhere in between.

Other new features arriving in v1.3.5 include support for a MIDI sustain/damper pedal, and the ability to shrink/stretch the piano key or ribbon size to a custom width. And if you’re using one of the new iPhone 5 or iPod touch devices with the 4” widescreen display, you’ll get extra keyboard space.

So, update to version 1.3.5 and you’ll soon be creating more of the awesome sounds for which Grain Science is known!

1. Reverb simulates listening to a sound inside of a virtual space, such as a room, cave, hallway, or cathedral. The “dry” sound is the part that comes directly from the sound, to your ear, as opposed to the part that bounces off the walls of the room in thousands of tiny echoes before hitting your ear