You are here

Optimise PC Internal Timing & Audio Recording With Cubase VST

Tips & Tricks By Martin Walker
Published June 1998

Optimise PC Internal Timing & Audio Recording With Cubase VST

Many PC owners still seem to have trouble tying MIDI and audio together, and timing remains the main problem area. Martin Walker attempts to pull all the strands together.

It all seemed so easy in the days when the Atari ST reigned supreme. Cubase came on a single floppy, and getting it up and running was a simple matter of putting the disk in the drive and turning on the computer. A few seconds later, Cubase would appear on screen, and that was it.

Now things have changed, and despite the huge leaps in technological progress over the last few years — and the fact that the current feature list for the latest Mac and PC versions of Cubase VST is enough to make anyone's mouth water — this progress has also increased the potential for problems.

One of the reasons the ST was so easy to deal with was that it included a built‑in MIDI port. The story goes that Jack Tramiel (boss of Atari at the time) asked his son if there were any other features that ought to be designed into the ST. Being a musician, the son suggested a MIDI port, and so it was incorporated from day one. The beauty of having MIDI built into the hardware was that every software developer could access MIDI In and Out signals directly, in a completely standard way.

To achieve perfect sync, both MIDI and audio must be referenced to a high‑resolution internal clock.

Getting A Buzz

Figure 1: Once you have finished entering the correct parameter values for your particular soundcard you will see a figure for latency in the Audio System Setup window, as shown here. The MIDI to Audio Delay compensates for slow MIDI hardware, and its setting is discussed in the main text.Figure 1: Once you have finished entering the correct parameter values for your particular soundcard you will see a figure for latency in the Audio System Setup window, as shown here. The MIDI to Audio Delay compensates for slow MIDI hardware, and its setting is discussed in the main text.

Early PCs had only primitive audio support — their only audio component was a tiny buzzer (or a 3‑inch loudspeaker if you were lucky) which produced a beep if an error message appeared on screen. Despite the best efforts of early developers, musical offerings were restricted by the speaker's pitiful 1‑bit resolution (ie. either a high or low voltage value), and even a simple sound like a 1kHz square wave tone needed software code to switch this voltage up or down 1000 times a second.

Faced with this situation, additional hardware was the only way to allow PCs to produce real music. Early soundcards such as the Adlib had 2‑operator Yamaha FM synth chips on board, but these were swiftly followed by the original Soundblaster card, which added 8‑bit digitised sound and a very basic MIDI interface. For professional musicians, however, it was only the arrival of the Roland MPU401 MIDI interface standard that enabled the PC to stand tall amongst its rivals, since the standard removed a host of problems that had plagued users of the early Soundblaster's MIDI sockets.

The standard PC MIDI interface (in the form of a plug‑in expansion card) enabled any external MIDI sound to be played back from a PC, but because the hardware expansion card was not a standard part of the computer, it had to be correctly set up so that it could be accessed by software running on the host computer. Most people are now reasonably familiar with the IRQ (Interrupt Request), DMA (Direct Memory Access), and I/O (Input/Output) addresses, all of which have to be correctly adjusted before PC software and hardware can communicate. Problems arise because the availability of these addresses depends entirely on what other hardware is installed in the PC.

Every hardware device accessed by your sequencer will take some processor overhead to run its software drivers, and audio hardware needs to be updated on a regular basis. The computer needs to look at the MIDI inputs regularly to deal with incoming data, and the sequencer will also be sending MIDI output data to one or more ports. At the same time, audio data must be read off the hard drive and sent to the soundcard's D‑A converters, and software synths may also be running in the background... You get the idea — every process needs to be updated regularly to keep everything in sync.

To achieve perfect sync, both MIDI and audio must be referenced to a high‑resolution internal clock. The highest resolution for audio is a single sample, whereas MIDI is generally referenced to 'ticks' (or 'pulses'), which are a tiny fraction of a quarter note (crotchet) in length. Cubase has a switchable resolution (found in the Synchronisation page) of up to 384ppqn (pulses per quarter note). At maximum resolution, a typical tempo of 120bpm, and assuming a sample rate of 44.1kHz, there will be about 57 samples per tick [he's right, you know — Maths Ed].

However, even music software capable of such high‑resolution sequencing is worthless if the connected hardware cannot cope with such a high resolution. There are all sorts of reasons why timing can be compromised, and many of them relate to hardware rather than the software. Only by understanding the issues can you resolve such hardware problems, and only then is it worth looking at problems that may be caused by VST itself. Incidentally, if you are running Logic Audio or Cakewalk Pro Audio, many of the hardware problems described here will be equally relevant, as will some of the software problems, though the parameters that require adjustment may go by different names.

Soundcard Settings

Figure 2: You can compensate for delays between audio input and output by adjusting offsets in the ASIO Multimedia Setup (see also Figure 3).Figure 2: You can compensate for delays between audio input and output by adjusting offsets in the ASIO Multimedia Setup (see also Figure 3).

Before you do anything else, it is vital to ensure that you use the settings recommended for your soundcard. Inside the Start menu folder for Cubase you should find the Troubleshooting text file (if not, you can find it manually wherever the Cubase files are stored, inside the Readme folder). This not only explains some basic principles of dealing with timing problems, but also has recommended settings for a range of soundcards. Steinberg provide a list of tested and recommended cards on their web site, and update it as new cards become available.

The first of these settings relates to the buffers, which are areas of RAM used to (hopefully) ensure steady audio output by storing enough audio data to cope with unexpected system glitches. The optimum number of audio buffers and their size can be found in the Troubleshooting text file, but if you are still not sure that your settings are right, you can use the Check Buffers and Sync option in Cubase VST (available since version 3.55). This is not infallible, however. The Buffer Size should be the same for all inputs and outputs on your soundcard.

There are several other settings that need to be adjusted to suit the make and model of soundcard and, although this information is readily available for major soundcards, it is still worth explaining what they are — not only for those of you using non‑recommended soundcards, but also because it helps to highlight some of the problems faced by software developers when attempting to support the full range of soundcards.

Sync Reference determines how Cubase synchronises MIDI playback to audio. The preferred setting (if your card supports it) is Sample Position, because this allows the soundcard itself to tell Cubase the current sample position during sample playback, and MIDI can then be synchronised to this. Since MIDI is locked to sample position, this mode is equivalent to sync'ing to a sample‑accurate external clock.

Sadly, not all soundcards support this mode, so if Cubase issues a warning to this effect when you first try it, you will instead have to select DMA (Direct Memory Access) Blocks as the sync reference (according to the Troubleshooting file, this issue should arise only with DAL's CardD+ and the Terratec EWS64XL). In this case, the software must keep track of the number of blocks that are transferred to the soundcard, and the number of audio buffers and their size must also be set accordingly. In the absence of specific settings, these values can be derived automatically using the Detect Buffer Size button under Advanced Options in the ASIO Multimedia Setup window. If you choose an inappropriate setting, audio and MIDI will drift apart in DMA Blocks mode.

There are also three Card Options to set. Full Duplex should be used when you want to record audio whilst playing back previously recorded material. Most soundcards released in the last couple of years can do this, but even if yours can't, you can still keep yourself in time whilst recording audio by monitoring MIDI playback, even though you can't hear any previously recorded audio at the same time. Be aware that there is a significant difference between versions 3.0 and 3.5 of Cubase in the way they handle full‑ and half‑duplex cards. Whereas Cubase v3.0 would work with half‑duplex cards (playback being suspended during recording), Cubase VST v3.5 was optimised for full‑duplex cards, a change that caused problems for some people when upgrading. If you want to make effective use of VST, you really do need a full‑duplex card.

For most cards the Start Input First option should be ticked, ensuring correct full‑duplex operation by always opening the input (recording) before the output (playback). The third and final option is Open All Devices Before Start, which is relevant only for multi‑channel cards. If you have such a card, you should turn this option on so that all the input and output ports will be in absolute sync.

Certain soundcards cause specific problems, though these can often be solved simply by obtaining an updated soundcard driver. Steinberg keep up‑to‑date information about specific driver problems on their web site, but if you are unsure whether your drivers are the latest versions, it is better to contact the individual card manufacturer (or look on their web site).

Getting The Jitters

Figure 3: The top track in this window, the Audio Editor, shows the 1ms WAV file click that I used for playback testing. Beneath this, the 'Before' waveforms show the 15ms pre‑delay that I measured when re‑recording this click back into the VST audio input, along with a synchronised MIDI woodblock sound. After adjusting the MIDI to Audio Delay (Figure 1), and the input offset (Figure 2), 'After' shows how everything is now perfectly in sync with the original audio click. However, 'After2' shows the variance of MIDI hardware timing — this next recording shows that the MIDI delay has changed by about 1ms. There is nothing that can be done about this.Figure 3: The top track in this window, the Audio Editor, shows the 1ms WAV file click that I used for playback testing. Beneath this, the 'Before' waveforms show the 15ms pre‑delay that I measured when re‑recording this click back into the VST audio input, along with a synchronised MIDI woodblock sound. After adjusting the MIDI to Audio Delay (Figure 1), and the input offset (Figure 2), 'After' shows how everything is now perfectly in sync with the original audio click. However, 'After2' shows the variance of MIDI hardware timing — this next recording shows that the MIDI delay has changed by about 1ms. There is nothing that can be done about this.

Various types of timing problems can arise in MIDI + audio sequencers with both MIDI and audio playback. One very basic problem, related to MIDI, is that of timing instability. This is when MIDI events recorded with strict timing are played back with a slightly random delay. This is particularly obvious in very rhythmic music, since any slight change from rock‑steady timing sticks out like a sore thumb. Instability such as this makes music sound unsure, or 'jittery'.

MIDI devices also always suffer from some latency (a delay between triggering and hearing a sound); this ranges between several milliseconds to several tens of milliseconds with particularly bad hardware designs. This is nothing to do with the sequencer software, but is due to the finite time required for the MIDI device to receive an input (MIDI) signal and then produce an output (audio) signal. In general, analogue synths tend to be faster in this respect than digital ones, and the delays involved are normally fairly constant, although they may vary with the number of notes played. If you have 'golden ears' where timing is concerned, you may find the offset facility useful. This is offered by most sequencers (including Cubase VST), and allows you to offset individual tracks in time relative to the others, by adding or subtracting a fixed offset. This can compensate for a noticeably slow MIDI device, although you may find that (apart from drums and percussion) you already tend to compensate for these delays by adapting your performance technique during recording.

So what are typical delay times produced by MIDI hardware? I took measurements of the average time taken to play back a single note. The delay for my DB50XG soundcard averaged out at an excellent 1ms, whilst a selection of external MIDI gear, including a Korg M1, Wavestation SR, and an Akai S2800i sampler, all came in at about 3ms — a more typical figure. Even Seer Systems' Reality software synth managed 8ms in Faster Response mode, and 18ms in More Voices mode, despite the fact that software synthesis is a notoriously difficult thing to do in real time. A Roland SC55 and Yamaha MU50 both measured about 6ms, and the Peavey DPM3, which appears to be one of the slowest MIDI devices around, could only manage 10ms (and up to 70ms to play 10 MIDI notes).

Cubase VST has a global MIDI to Audio Delay setting (see Figure 1) that you can use to provide an average adjustment to suit your selection of MIDI devices. If you want to try tweaking this, you need to set up a dummy sequence which plays a short clicky WAV sound at exactly the same time as a short MIDI sound (such as a woodblock). Route your audio outputs to your external mixer, and the output of the mixer back to the inputs of the soundcard. Then set up another Cubase VST stereo audio track, and record the audio click to one of the two mono channels of the pair, and the MIDI click to the other, both via the mixer. Now examine the stereo WAV file in an editor such as WaveLab to measure the time delay between the audio and MIDI. It is worth doing this several times, as the value will vary a little. Remember that it will also vary between each of your MIDI devices. A value of 44 samples at 44.1kHz sample rate corresponds to 1ms. Dan Duskin's excellent web site (www.instanet.com/~thedusk/) has detailed step‑by‑step instructions on measuring time delays, as well as a huge range of other tweaks and optimisations for Cubase VST.

Since the average soundcard may be called upon to perform several tasks at once — replay audio, run an on‑board MIDI synth, and maybe even run a second software MIDI synth as well — timing may be better on some jobs than on others. Some soundcards are also better than others where MIDI interface timing instability is concerned. There is nothing you can do in VST to change this, although updated soundcard drivers can sometimes improve matters.

The Latent Solution

Figure 4: Having noted down your latency figure from the Audio System Setup window (see Figure 2), go to the Synchronisation window and change the entry for System Preroll to exactly the same value. This alone will cure many timing problems (see main text for more details)Figure 4: Having noted down your latency figure from the Audio System Setup window (see Figure 2), go to the Synchronisation window and change the entry for System Preroll to exactly the same value. This alone will cure many timing problems (see main text for more details)

Another problem is that all Windows 95 audio recording applications have what is known as a latency value; effectively a delay between action and reaction, and a value that depends on buffering. For reliable glitch‑free audio operation in Cubase VST, each soundcard will need a certain size and number of buffers which in turn determine the latency value. This does not mean that the audio will actually be delayed, just that it is being prepared ahead of the time when it is actually sent to the soundcard for playback — the only time you notice the full delay is when you press the play button, since it takes this long to initially fill up the buffers.

Whilst the audio playback is automatically adjusted to remain exactly in sync with MIDI, there will also be an unavoidable delay on the audio recording side, and if you try to monitor the signal you are recording in real time, particularly if you are applying effects or EQ that require processor time, you will hear this delay. The reason why soundcard‑specific ASIO drivers are now so eagerly awaited (as an alternative to the generic ASIO Multimedia driver) is that a specific ASIO driver is much more closely integrated with Cubase VST than a driver that goes through the standard Windows 95 MME system, and so the delays that arise tend to be significantly lower. Not only does this make monitoring an audio input with real‑time effects more feasible, but real‑time items such as channel meters will be far less sluggish, and will appear more closely in sync with the signals they are monitoring.

Apparently the single biggest cause of Cubase VST timing problems is one related to the latency value, in the form of an incorrect Preroll setting — the UK Steinberg helpline reports that upwards of 80% of MIDI timing problems have been solved by changing this value. The System Preroll parameter can be found in the Synchronisation window, and its default value is 250ms (increased to 500ms in later versions). Given that the wrong value can cause so many problems, there is still little in the VST electronic manual to indicate its importance (what there is can be found on page 437). So: what is it and, more to the point, why is the default value not suitable in so many cases?

The Preroll is a buffer used to store MIDI information before it is needed. If enough information has been prepared in advance, it can emerge at a steady rate despite occasional pauses due to other factors in the system. This is very much like the buffer in a CD‑R drive, which ensures that the writing process carries on smoothly despite the hard drive pausing occasionally to do other things — as long as there is still data in the buffer, it will continue to emerge at a steady rate, and the processor can top it up as soon as it has finished with whatever caused the interruption.

The most suitable value for this Preroll setting is the same as the latency value, which you can find in the Audio System Setup window (see Figure 2). Since the start of audio playback will be delayed by the latency time, if the Preroll value is shorter than this then the MIDI tracks may start before the audio is ready, with the result that the first part of the audio is missed altogether. By setting its value to at least the same as the audio latency, it can never start before the audio, so both MIDI and audio have time to be totally prepared before the music actually starts. Increasing the Preroll setting still further can occasionally overcome other problems, but you will begin to notice a very sluggish start to your music.

Drivers & Other Problems

Your soundcard's software drivers, coupled with the design of the soundcard hardware, may also affect timing. When the program tells the soundcard to start playing back an audio file, there will be a finite delay before any sound is heard. These delays will be relatively small, but again it is possible to measure their size and compensate for them. You can do this by importing and playing back through Cubase VST a WAV file of a short, clicky sound, and then re‑record this using the VST audio input. By comparing the timing of the re‑recorded version with the original, you will discover the exact offset caused by the audio passing through the output and then returning through the input. You can therefore adjust the input timing offset (again, Dan Duskin's site has more details on a way of measuring this, and you can see in Figure 3 how my system was improved).

Some of you might think that Steinberg ought to provide an automatic adjustment for these delays, but the fact is they are not under the control of Cubase, and the only solution is to measure them as detailed above. For those of you wondering whether it is worth the effort, consider the scenario where you attempt to use external hardware effects with VST — unless you compensate for the soundcard delays, the returning 'wet' signal will be slightly delayed with respect to the 'dry' signal, and will therefore give an additional slapback delay which you may not want. Remember that this measurement only needs to be repeated if you change your soundcard (and possibly your soundcard drivers), since VST compensates internally for its own delays.

Long‑Term Drift Problems

If you want to run another audio recorder (such as an ADAT or an analogue tape machine) alongside VST, you will need to consider how to keep them synchronised. Normally, the clock for digital audio is provided by the soundcard hardware, and VST slaves the MIDI playback to this — you just select Audio Clock in the Audio System Setup window under MIDI Sync Reference.

If you want to sync MIDI to incoming MTC (MIDI Time Code), however, in order to reference to an external recorder, you select the MTC option instead. The audio will still start at exactly the right place, but it will probably drift out of sync as playback continues, since its internal hardware clock is entirely unconnected to MTC. You may be able to work like this on short pieces, though it is not really a good idea since the audio playback is effectively 'free‑wheeling'.

This is the cause of most long‑term drift problems, along with attempting to run several soundcards at the same time without any form of hardware sync between them. In this latter case, you are totally dependent on the stability of each of the soundcard internal clocks; some people have managed to run for several minutes without noticing any drift between them, and using two cards of the same make or model certainly helps.

To sync both MIDI and audio to an external source, you need a hardware sync signal for the audio, which means an appropriate digital signal input to the audio soundcard. The best solution is word clock, but some soundcard drivers offer a similar facility from an S/PDIF digital audio input. With multiple soundcards, you should lock the cards together — as an example, the latest version of the Event Gina/Darla drivers permit this by connecting the S/PDIF output of the first to the S/PDIF input of the next, so that the clock for the second card is provided by the first.

Summary

Personally, I haven't had any major problems with VST on my Pentium 166 MMX system, but I can think of several reasons why this is so: firstly, I use a Gina card (other users have reported miraculous cures for their system problems as soon as they have installed one); I rarely use more than three or four audio tracks (most of my music is still MIDI‑based); and I visit the Steinberg web site regularly and implement all the settings they recommend. The most annoying problem (which still crops up occasionally) is that the audio playback disappears altogether. I have still not tracked down the cause, partly because there seems to be an easy cure if this happens — go into the Audio System Setup window, change the Number of Channels (any different number will do), click on Apply to make this take effect, change the Number of Channels back to what it was before, and click Apply again. This hasn't failed me yet, although it doesn't make the problem any less annoying.

It does seem that most VST users with a Pentium 166MHz or better are achieving at least eight audio tracks, and that most of the reported MIDI timing problems are cured instantly when the Preroll value is set as recommended. The remaining problems seem to be largely caused by rogue soundcards or MIDI interfaces, or indeed by their drivers. Try to make sure that any card you buy supports Sample Position (most modern ones do), since this makes the sync between audio and MIDI a lot easier to achieve.

General Tweaks

Although it might be said that Cubase VST either works or it doesn't, many people are straining to squeeze the last drop of performance out of their PC, or even desperately tweaking a low‑end machine in a struggle to achieve the performance required for reliable operation. Steinberg provide several adjustments in Audio System Setup that you can try, which may help in some cases.

The File Cache Scheme settings adjust the way Cubase stores audio from the hard drive before sending it to the soundcard. The Virtual Tape Recorder option is most suitable if you record long tracks in one take, since file caching is not very helpful in this case. The Audio Sequencer option is ideal if you record with lots of short repeated snippets of audio (like drum loops for instance) — caching can then give a healthy performance boost, as the same audio data is likely to still be in the cache, rather than having to be re‑read from the hard drive. The final Tape Recorder/Audio Sequencer option is a compromise between the other two settings.

The other main parameter for general tweaks is Priority (again in Audio System Setup), which lets you decide the relative importance of MIDI and audio, as far as timing is concerned. The Normal setting gives equal priority to each, but you can select Low if you use relatively little audio and want to give MIDI more importance. The other two settings, High and Highest, give more importance to audio timing — if you need lots of audio tracks and are struggling, selecting these may help you, but at the expense of MIDI timing and the sluggishness of the user interface. Priority is saved in the DEF.ALL preferences file, and so is set every time you boot up VST; other settings are saved on a song‑by‑song basis — see the Cubase VST electronic manual for more details.

Cubase Versions

The first version of Cubase VST was 3.50, so named because it was a major update from Cubase v3.0, and this was quickly updated with a few bug fixes to version 3.501.The only ones that I noticed were that the Shift+Page Up keyboard shortcut for Fast Forward hadn't worked, and that if the mouse was clicked on the transport bar, the Alt key didn't activate the main menus.

Some people also found that the Save As function was not working in their systems; this was fixed in version 3.502, along with a bug causing problems with ActiveMovie (now known as DirectX) if Microsoft's Internet Explorer 4 had been installed (Internet Explorer arrived after 3.501, so it was impossible for Steinberg to anticipate this problem).

The next major change was the launch of version 3.55, which added optional effect inserts to each audio channel. Previously, setting up in‑line effects such as compressors was a bit involved, but they were now easy to add to the audio chain. DirectX plug‑in handling was improved, with the ability to selectively disable any plug‑in that was only relevant to another package, and support was added for DirectX soundcard drivers. The ASIO Multimedia Setup was tweaked, with the addition of the Check Buffers And Sync option, and the Disable Audio option provided a way to return to MIDI‑only operation, without draining extra resources when not using audio.

The most recent version is 3.551, released at the 1998 Frankfurt Musikmesse. The entire driver architecture has apparently been "rewritten and optimised for even more solid synchronisation of MIDI and audio and external devices as drum machines, hardware sequencers or tape or video machines". Steinberg also added the higher quality EQ1 option (originally only provided with WaveLab), which extends the normal +/‑12dB EQ range to +/‑24dB.

Intermittent And Short Timing Glitches

These can be caused by an incorrectly adjusted graphics card driver (see the October 1997 PC Notes for more details), or a badly fragmented hard drive, which may spend too much time jumping about trying to read all the fragmented audio segments, such that audio playback becomes intermittent or is interrupted.

Sadly, some older soundcards (or even newer ones without the latest drivers) can cause performance problems. Some VST crashes have also been traced to MIDI interface drivers, so make sure you have the latest versions. Peter Buick (author of the Cubase Power Users Guide ) found that his Pentium 120MHz machine couldn't manage any audio tracks at all with an elderly Aztec 32 Duplex card (which only supports DMA Block transfers), but when he managed to borrow an Event Gina soundcard he immediately got eight playback tracks!

Look under the performance tab of System Properties in Control Panel — if it says 'Your system is configured for optimal performance', then your PC is not using any DOS drivers. If it is, they will be listed, and will affect disk access quite heavily, slowing everything right down. CD‑ROM drivers are the worst for this, although happily, most drives now have Windows 95 drivers. The solution is to contact the manufacturer of the hardware that needs this driver, and obtain a Windows 95 version.

The Steinberg web site reports that Ultra DMA/33 hard drives have been found to cause MIDI timing instabilities with certain motherboard/BIOS/soundcard combinations. If you have only experienced problems since installing a new faster drive, there is a fix involving a change to the plug and play Configuration page in the BIOS that has helped some people. Full details can be found at the Steinberg UK site at dialspace.dial.pipex.com/town/road/gbp97/.

Finally, don't blame VST if your system becomes a little 'clunky' when you try to run too many plug‑ins — the amount of processor power used by these is independent of VST, and depends solely on the plug‑in and your CPU speed. One thing to watch out for is that the VST Performance window indicates total CPU power available, and not just that available for VST alone. You should try to keep this below about 70%, or you may experience bad audio glitching.