diff --git a/src/m_sched.c b/src/m_sched.c
index 76f24a78a42b099c9a4a0606e433228970abc0bb..411d1963937d1ef88f6784ef68b5799ead9b05c0 100644
--- a/src/m_sched.c
+++ b/src/m_sched.c
@@ -450,11 +450,11 @@ static void m_pollingscheduler( void)
                 if (!(idlecount & 31))
                 {
                     static double idletime;
-                                        if (sched_useaudio != SCHED_AUDIO_POLL)
-                                        {
-                                                bug("m_pollingscheduler\n");
-                                                return;
-                                        }
+                    if (sched_useaudio != SCHED_AUDIO_POLL)
+                    {
+                            bug("m_pollingscheduler\n");
+                            return;
+                    }
                         /* on 32nd idle, start a clock watch;  every
                         32 ensuing idles, check it */
                     if (idlecount == 32)
@@ -566,6 +566,15 @@ int m_mainloop(void)
     return (0);
 }
 
+int m_batchmain(void)
+{
+    sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
+        ((double)sys_schedblocksize) / sys_dacsr;
+    while (sys_quit != SYS_QUIT_QUIT)
+        sched_tick(sys_time + sys_time_per_dsp_tick);
+    return (0);
+}
+
 /* ------------ thread locking ------------------- */
 
 #ifdef THREAD_LOCKING
diff --git a/src/s_main.c b/src/s_main.c
index 0bc5a191ebf359cfda4d0fa864c7a8e1946d75ae..cb4bf7afabdfcb5dc540645a3d86e129bd2095de 100644
--- a/src/s_main.c
+++ b/src/s_main.c
@@ -35,6 +35,7 @@ void sys_findprogdir(char *progname);
 int sys_startgui(const char *guipath);
 int sys_rcfile(void);
 int m_mainloop(void);
+int m_batchmain(void);
 void sys_addhelppath(char *p);
 #ifdef USEAPI_ALSA
 void alsa_adddev(char *name);
@@ -75,6 +76,7 @@ static int sys_listplease;
 
 int sys_externalschedlib;
 char sys_externalschedlibname[MAXPDSTRING];
+static int sys_batch;
 int sys_extraflags;
 char sys_extraflagsstring[MAXPDSTRING];
 int sys_run_scheduler(const char *externalschedlibname,
@@ -299,6 +301,8 @@ int sys_main(int argc, char **argv)
     if (sys_externalschedlib)
         return (sys_run_scheduler(sys_externalschedlibname,
             sys_extraflagsstring));
+    else if (sys_batch)
+        return (m_batchmain());
     else
     {
             /* open audio and MIDI */
@@ -394,6 +398,7 @@ static char *(usagemessage[]) = {
 "-nosleep         -- spin, don't sleep (may lower latency on multi-CPUs)\n",
 "-schedlib <file> -- plug in external scheduler\n",
 "-extraflags <s>  -- string argument to send schedlib\n",
+"-batch           -- run off-line as a batch process\n",
 };
 
 static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
@@ -828,6 +833,12 @@ int sys_argparse(int argc, char **argv)
             argv += 2;
             argc -= 2;
         }
+        else if (!strcmp(*argv, "-batch"))
+        {
+            sys_batch = 1;
+            sys_printtostderr = sys_nogui = 1;
+            argc--; argv++;
+        }
 #ifdef UNISTD
         else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime"))
         {