diff -urN snes9x-1.51-src-orig/controls.cpp snes9x-1.51-src/controls.cpp
--- snes9x-1.51-src-orig/controls.cpp	2007-04-29 09:51:16 +0900
+++ snes9x-1.51-src/controls.cpp	2009-12-27 15:56:35 +0900
@@ -182,6 +182,7 @@
 #include "snapshot.h"
 #include "spc7110.h"
 #include "movie.h"
+#include "logger.h"
 #ifdef NETPLAY_SUPPORT
 #include "netplay.h"
 #endif
@@ -320,6 +321,8 @@
     S(Pause), \
     S(QuickLoad000), S(QuickLoad001), S(QuickLoad002), S(QuickLoad003), S(QuickLoad004), S(QuickLoad005), S(QuickLoad006), S(QuickLoad007), S(QuickLoad008), S(QuickLoad009), S(QuickLoad010), \
     S(QuickSave000), S(QuickSave001), S(QuickSave002), S(QuickSave003), S(QuickSave004), S(QuickSave005), S(QuickSave006), S(QuickSave007), S(QuickSave008), S(QuickSave009), S(QuickSave010), \
+    S(RecordAudioStart), \
+    S(RecordAudioStop), \
     S(Reset), \
     S(SaveFreezeFile), \
     S(SaveSPC), \
@@ -1768,6 +1771,31 @@
                     Snapshot(filename);
                 }
                 break;
+              case RecordAudioStart:
+                {
+                    char def [PATH_MAX];
+                    char filename [PATH_MAX];
+                    char drive [_MAX_DRIVE];
+                    char dir [_MAX_DIR];
+                    char ext [_MAX_EXT];
+
+                    _splitpath (Memory.ROMFilename, drive, dir, def, ext);
+                    strcpy (ext, "pcm");
+                    _makepath (filename, drive, S9xGetDirectory (SPC_DIR),
+                               def, ext);
+                    if (RecordAudio (filename))
+                        sprintf (buf, "Recording to %s.%s", def, ext);
+                    else
+                        sprintf (buf, "Failed to start recording to %s.%s (%s)",
+                                 def, ext, strerror (errno));
+
+                    S9xSetInfoString (buf);
+                }
+                break;
+              case RecordAudioStop:
+                RecordAudio (NULL);
+                S9xSetInfoString ("Recording stopped");
+                break;
               case SaveSPC:
                 {
                     char def [PATH_MAX];
diff -urN snes9x-1.51-src-orig/logger.cpp snes9x-1.51-src/logger.cpp
--- snes9x-1.51-src-orig/logger.cpp	2007-04-29 09:51:22 +0900
+++ snes9x-1.51-src/logger.cpp	2009-12-27 15:56:35 +0900
@@ -257,6 +257,23 @@
 	resetno++;
 }
 
+int RecordAudio(const char *path)
+{
+	if (audio) {
+		fclose(audio);
+		audio = NULL;
+	}
+	if (path != NULL) {
+		audio = fopen(path, "wb");
+		if (!audio) {
+			printf("Opening %s failed. Recording cancelled.\n", path);
+			return 0;
+		}
+	}
+	return 1;
+}
+
+
 char message[128];
 int messageframe;
 
diff -urN snes9x-1.51-src-orig/logger.h snes9x-1.51-src/logger.h
--- snes9x-1.51-src-orig/logger.h	2007-04-29 09:51:20 +0900
+++ snes9x-1.51-src/logger.h	2009-12-27 15:56:35 +0900
@@ -172,6 +172,7 @@
 void Logger_NextFrame();
 
 void ResetLogger();
+int RecordAudio(const char *path);
 void VideoLogger(void *pixels, int width, int height, int depth, int bytes_per_row);
 void AudioLogger(void *samples, int length);
 
diff -urN snes9x-1.51-src-orig/soundux.cpp snes9x-1.51-src/soundux.cpp
--- snes9x-1.51-src-orig/soundux.cpp	2007-04-29 14:19:58 +0900
+++ snes9x-1.51-src/soundux.cpp	2009-12-27 16:09:14 +0900
@@ -171,6 +171,7 @@
 #include "apu.h"
 #include "memmap.h"
 #include "soundux.h"
+#include "logger.h"
 
 // gaussian table by libopenspc and SNEeSe
 static const int32 gauss[512] =
@@ -2137,6 +2138,9 @@
 			}
 		}
 	}
+
+	// Record audio if enabled
+	AudioLogger(buffer, so.sixteen_bit ? sample_count << 1 : sample_count);
 }
 
 #ifdef __DJGPP
diff -urN snes9x-1.51-src-orig/unix/svga.cpp snes9x-1.51-src/unix/svga.cpp
--- snes9x-1.51-src-orig/unix/svga.cpp	2007-04-29 09:51:08 +0900
+++ snes9x-1.51-src/unix/svga.cpp	2009-12-27 15:56:35 +0900
@@ -1023,6 +1023,8 @@
         keymaps.push_back(strpair_t("K00:C+F11", "SoundChannel7"));
         keymaps.push_back(strpair_t("K00:A+F12", "SoundChannelsOn"));
         keymaps.push_back(strpair_t("K00:C+F12", "SoundChannelsOn"));
+        keymaps.push_back(strpair_t("K00:C+R", "RecordAudioStart"));
+        keymaps.push_back(strpair_t("K00:C+T", "RecordAudioStop"));
 
 //        keymaps.push_back(strpair_t("M00:B0", "{Mouse1 L,Superscope Fire,Justifier1 Trigger}"));
 //        keymaps.push_back(strpair_t("M00:B1", "{Justifier1 AimOffscreen Trigger,Superscope AimOffscreen}"));
diff -urN snes9x-1.51-src-orig/unix/unix.cpp snes9x-1.51-src/unix/unix.cpp
--- snes9x-1.51-src-orig/unix/unix.cpp	2007-04-29 09:51:08 +0900
+++ snes9x-1.51-src/unix/unix.cpp	2009-12-27 16:43:56 +0900
@@ -1954,7 +1954,6 @@
 	    }
 	    S9xMixSamplesO (Buf, sc,
 			    byte_offset & SOUND_BUFFER_SIZE_MASK);
-            AudioLogger(Buf, byte_count);
 	    so.samples_mixed_so_far += sc;
 	    sample_count -= sc;
 	    bytes_so_far = so.sixteen_bit ? (so.samples_mixed_so_far << 1) :
@@ -2068,6 +2067,10 @@
 	    /*memset (Buf + (byte_offset & SOUND_BUFFER_SIZE_MASK), 0,
 		    sample_count - so.samples_mixed_so_far);*/
 	}
+	else if (Settings.SoundSync == 1)
+	{
+	    sample_count = so.samples_mixed_so_far;
+	}
 	else
 	{
 	    /* Mix the missing samples */
diff -urN snes9x-1.51-src-orig/unix/x11.cpp snes9x-1.51-src/unix/x11.cpp
--- snes9x-1.51-src-orig/unix/x11.cpp	2007-04-29 09:51:08 +0900
+++ snes9x-1.51-src/unix/x11.cpp	2009-12-27 15:56:35 +0900
@@ -2767,6 +2767,8 @@
         keymaps.push_back(strpair_t("K00:C+F11", "SoundChannel7"));
         keymaps.push_back(strpair_t("K00:A+F12", "SoundChannelsOn"));
         keymaps.push_back(strpair_t("K00:C+F12", "SoundChannelsOn"));
+        keymaps.push_back(strpair_t("K00:C+r", "RecordAudioStart"));
+        keymaps.push_back(strpair_t("K00:C+t", "RecordAudioStop"));
 
         keymaps.push_back(strpair_t("M00:B0", "{Mouse1 L,Superscope Fire,Justifier1 Trigger}"));
         keymaps.push_back(strpair_t("M00:B1", "{Justifier1 AimOffscreen Trigger,Superscope AimOffscreen}"));
