shithub: aacenc

Download patch

ref: 7c48e1435506c392728894d86a27c339b7f6bec5
parent: f7eb13670a2aabafd990a84dd91f14cce156bc1a
author: menno <menno>
date: Tue Jan 23 18:02:36 EST 2001

Added graphical user interface

--- /dev/null
+++ b/frontend/faacgui.dsp
@@ -1,0 +1,123 @@
+# Microsoft Developer Studio Project File - Name="faacgui" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=faacgui - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "faacgui.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "faacgui.mak" CFG="faacgui - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "faacgui - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "faacgui - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "faacgui - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "faacgui___Win32_Release"
+# PROP BASE Intermediate_Dir "faacgui___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseGUI"
+# PROP Intermediate_Dir "ReleaseGUI"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x413 /d "NDEBUG"
+# ADD RSC /l 0x413 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+# ADD LINK32 libsndfile.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF  "$(CFG)" == "faacgui - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "faacgui___Win32_Debug"
+# PROP BASE Intermediate_Dir "faacgui___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugGUI"
+# PROP Intermediate_Dir "DebugGUI"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x413 /d "_DEBUG"
+# ADD RSC /l 0x413 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 libsndfile.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "faacgui - Win32 Release"
+# Name "faacgui - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\maingui.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\include\faac.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE="E:\Program Files\Microsoft Visual Studio\VC98\Include\sndfile.h"
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\faacgui.rc
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null
+++ b/frontend/faacgui.dsw
@@ -1,0 +1,44 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "faacgui"=.\faacgui.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name libfaac
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "libfaac"=..\libfaac\libfaac.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null
+++ b/frontend/faacgui.rc
@@ -1,0 +1,123 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_MAINDIALOG DIALOGEX 0, 0, 266, 170
+STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | 
+    WS_SYSMENU
+CAPTION "FAAC GUI"
+FONT 8, "MS Sans Serif"
+BEGIN
+    PUSHBUTTON      "...",IDC_SELECT_INPUTFILE,228,12,19,14,0,
+                    WS_EX_STATICEDGE
+    PUSHBUTTON      "...",IDC_SELECT_OUTPUTFILE,228,32,19,14,WS_DISABLED,
+                    WS_EX_STATICEDGE
+    CONTROL         "Allow Mid/Side",IDC_ALLOWMIDSIDE,"Button",
+                    BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,17,78,63,10
+    EDITTEXT        IDC_BITRATE,142,73,69,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_BANDWIDTH,142,93,69,14,ES_AUTOHSCROLL
+    DEFPUSHBUTTON   "Encode",IDOK,75,149,50,14,WS_DISABLED
+    PUSHBUTTON      "Quit",IDCANCEL,141,149,50,14
+    EDITTEXT        IDC_INPUTFILENAME,61,12,161,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_OUTPUTFILENAME,61,32,161,14,ES_AUTOHSCROLL | 
+                    WS_DISABLED
+    LTEXT           "Input File:",IDC_STATIC,18,13,38,8
+    LTEXT           "Output File:",IDC_STATIC,18,34,37,8
+    CONTROL         "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,54,
+                    252,1
+    LTEXT           "-",IDC_INPUTPARAMS,32,66,55,8
+    LTEXT           "In:",IDC_STATIC,18,66,12,8
+    CONTROL         "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,
+                    120,252,10
+    GROUPBOX        "Output Format",IDC_STATIC,94,62,153,51
+    CTEXT           "- - -",IDC_TIME,7,136,252,8
+    LTEXT           "Bandwidth:",IDC_STATIC,101,96,37,8
+    LTEXT           "Bitrate:",IDC_STATIC,101,76,37,8
+    LTEXT           "bps/ch",IDC_STATIC,218,76,24,8
+    LTEXT           "Hz",IDC_STATIC,218,96,10,8
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_MAINDIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 259
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 163
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- /dev/null
+++ b/frontend/maingui.c
@@ -1,0 +1,351 @@
+/*
+ * FAAC - Freeware Advanced Audio Coder
+ * Copyright (C) 2001 Menno Bakker
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * $Id: maingui.c,v 1.1 2001/01/23 23:02:15 menno Exp $
+ */
+
+#include <windows.h>
+#include <commdlg.h>
+#include <commctrl.h>
+#include <stdio.h>
+
+#include <sndfile.h>
+
+#include "faac.h"
+#include "resource.h"
+
+#define PCMBUFSIZE 1024
+#define BITBUFSIZE 8192
+
+static HINSTANCE hInstance;
+
+static char inputFilename[_MAX_PATH], outputFilename [_MAX_PATH];
+
+static BOOL SelectFileName (HWND hParent, char *filename, BOOL forReading)
+{
+	OPENFILENAME ofn;
+
+	ofn.lStructSize = sizeof(OPENFILENAME);
+	ofn.hwndOwner = hParent;
+	ofn.hInstance = hInstance;
+	ofn.nFilterIndex = 0;
+	ofn.lpstrFileTitle = NULL;
+	ofn.nMaxFileTitle = 31;
+	filename [0] = 0x00;
+	ofn.lpstrFile = (LPSTR)filename;
+	ofn.nMaxFile = _MAX_PATH;
+	ofn.lpstrInitialDir = NULL;
+	ofn.lpstrCustomFilter = NULL;
+	ofn.nMaxCustFilter = 0;
+	ofn.nFileOffset = 0;
+	ofn.nFileExtension = 0;
+	ofn.lCustData = 0;
+	ofn.lpfnHook = NULL;
+	ofn.lpTemplateName = NULL;
+
+	if (forReading)
+	{
+		char filters[] = { "Wave Files (*.wav)\0*.wav\0" \
+			"All Files (*.*)\0*.*\0\0" };
+
+		ofn.lpstrFilter = filters;
+		ofn.lpstrDefExt = "wav";
+
+		ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+		ofn.lpstrTitle = "Select Source File";
+
+		return GetOpenFileName (&ofn);
+	} else {
+		char filters [] = { "AAC Files (*.aac)\0*.aac\0" \
+			"All Files (*.*)\0*.*\0\0" };
+
+		ofn.lpstrFilter = filters;
+		ofn.lpstrDefExt = "aac";
+
+		ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+		ofn.lpstrTitle = "Select Output File";
+
+		return GetSaveFileName(&ofn);
+	}
+}
+
+static void AwakeDialogControls(HWND hWnd)
+{
+	char szTemp[64];
+	SNDFILE *infile;
+	SF_INFO sfinfo;
+	unsigned int sampleRate, numChannels;
+	char *pExt;
+	faacEncHandle hEncoder;
+
+	if ((infile = sf_open_read(inputFilename, &sfinfo)) == NULL)
+		return;
+
+	/* determine input file parameters */
+	sampleRate = sfinfo.samplerate;
+	numChannels = sfinfo.channels;
+
+	sf_close(infile);
+
+	// // //
+
+	SetDlgItemText (hWnd, IDC_INPUTFILENAME, inputFilename);
+
+	strncpy(outputFilename, inputFilename, sizeof(outputFilename) - 5);
+
+	pExt = strrchr(outputFilename, '.');
+
+	if (pExt == NULL) strcat(outputFilename, ".aac");
+	else strcpy(pExt, ".aac");
+
+	EnableWindow(GetDlgItem(hWnd, IDC_OUTPUTFILENAME), TRUE);
+	EnableWindow(GetDlgItem(hWnd, IDC_SELECT_OUTPUTFILE), TRUE);
+
+	SetDlgItemText(hWnd, IDC_OUTPUTFILENAME, outputFilename);
+
+	wsprintf(szTemp, "%iHz %s", sampleRate, (numChannels > 1) ? "Stereo" : "Mono");
+	SetDlgItemText(hWnd, IDC_INPUTPARAMS, szTemp);
+
+	// // //
+
+	hEncoder = faacEncOpen(sampleRate, numChannels);
+	if (hEncoder)
+	{
+		faacEncConfigurationPtr config;
+
+		SendDlgItemMessage (hWnd, IDC_OUTPUTFORMAT, CB_RESETCONTENT, 0, 0L);
+
+		EnableWindow(GetDlgItem(hWnd, IDC_OUTPUTFORMAT), TRUE);
+		EnableWindow(GetDlgItem(hWnd, IDOK), TRUE);
+
+		config = faacEncGetCurrentConfiguration(hEncoder);
+
+		config->allowMidside = IsDlgButtonChecked(hWnd, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
+		GetDlgItemText(hWnd, IDC_BITRATE, szTemp, sizeof(szTemp));
+		config->bitRate = atoi(szTemp);
+		GetDlgItemText(hWnd, IDC_BANDWIDTH, szTemp, sizeof(szTemp));
+		config->bandWidth = atoi(szTemp);
+
+		faacEncSetConfiguration(hEncoder, config);
+
+		faacEncClose(hEncoder);
+	} else {
+		MessageBeep(1);
+	}
+}
+
+static void EncodeFile(HWND hWnd)
+{
+	SNDFILE *infile;
+	SF_INFO sfinfo;
+
+	GetDlgItemText(hWnd, IDC_INPUTFILENAME, inputFilename, sizeof(inputFilename));
+	GetDlgItemText(hWnd, IDC_OUTPUTFILENAME, outputFilename, sizeof(outputFilename));
+
+	/* open the input file */
+	if ((infile = sf_open_read(inputFilename, &sfinfo)) != NULL)
+	{
+		/* determine input file parameters */
+		unsigned int sampleRate = sfinfo.samplerate;
+		unsigned int numChannels = sfinfo.channels;
+
+		/* open and setup the encoder */
+		faacEncHandle hEncoder = faacEncOpen(sampleRate, numChannels);
+		if (hEncoder)
+		{
+			HANDLE hOutfile;
+			char szTemp[64];
+
+			/* set encoder configuration */
+			faacEncConfigurationPtr config = faacEncGetCurrentConfiguration(hEncoder);
+
+			config->allowMidside = IsDlgButtonChecked(hWnd, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
+			GetDlgItemText(hWnd, IDC_BITRATE, szTemp, sizeof(szTemp));
+			config->bitRate = atoi(szTemp);
+			GetDlgItemText(hWnd, IDC_BANDWIDTH, szTemp, sizeof(szTemp));
+			config->bandWidth = atoi(szTemp);
+
+			if (!faacEncSetConfiguration(hEncoder, config))
+			{
+				faacEncClose(hEncoder);
+				sf_close(infile);
+
+				MessageBox (hWnd, "faacEncSetConfiguration failed!", "Error", MB_OK | MB_ICONSTOP);
+				return;
+			}
+
+			/* open the output file */
+			hOutfile = CreateFile(outputFilename, GENERIC_WRITE, 0, NULL,
+				CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+			if (hOutfile != INVALID_HANDLE_VALUE)
+			{
+				UINT startTime = GetTickCount(), lastUpdated = 0;
+				DWORD totalBytesRead = 0;
+
+				// //
+
+				unsigned int bytesInput = 0, bytesConsumed = 0;
+				DWORD numberOfBytesWritten = 0;
+				unsigned char bitbuf[BITBUFSIZE];
+				short pcmbuf[PCMBUFSIZE];
+
+				SendDlgItemMessage(hWnd, IDC_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0, 1024));
+				SendDlgItemMessage(hWnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);
+
+				for ( ;; )
+				{
+					MSG msg;
+					int bytesWritten;
+					int samplesToRead = PCMBUFSIZE;
+					UINT timeElapsed, timeEncoded;
+
+					bytesInput = sf_read_short(infile, pcmbuf, numChannels*PCMBUFSIZE) * sizeof(short);
+
+					SendDlgItemMessage (hWnd, IDC_PROGRESS, PBM_SETPOS, (unsigned long)((float)totalBytesRead * 1024.0f / (sfinfo.samples*2*numChannels)), 0);
+
+					totalBytesRead += bytesInput;
+
+					timeElapsed = (GetTickCount () - startTime) / 1000;
+					timeEncoded = totalBytesRead / (sampleRate * numChannels * sizeof (short));
+
+					if (timeElapsed > lastUpdated)
+					{
+						float factor;
+
+						lastUpdated = timeElapsed;
+
+						factor = (float) timeEncoded / (float) (timeElapsed ? timeElapsed : 1);
+
+						sprintf(szTemp, "Playing time: %2.2i:%2.2i:%2.2i  Encoding time: %2.2i:%2.2i:%2.2i  Factor: %.1f",
+							timeEncoded / 3600, (timeEncoded % 3600) / 60, timeEncoded % 60,
+							timeElapsed / 3600, (timeElapsed % 3600) / 60, timeElapsed % 60,
+							factor);
+
+						SetDlgItemText(hWnd, IDC_TIME, szTemp);
+					}
+
+					/* call the actual encoding routine */
+					bytesWritten = faacEncEncode(hEncoder,
+						pcmbuf,
+						bytesInput/2,
+						bitbuf,
+						BITBUFSIZE);
+
+					/* all done, bail out */
+					if (!bytesInput && !bytesWritten)
+						break;
+
+					if (bytesWritten < 0)
+					{
+						MessageBox (hWnd, "faacEncEncodeFrame failed!", "Error", MB_OK | MB_ICONSTOP);
+						break;
+					}
+
+					WriteFile(hOutfile, bitbuf, bytesWritten, &numberOfBytesWritten, NULL);
+
+					/* for the sake of structural simplicity, we're a modal dialog
+					   and we do not run the encoder in a separate worker thread */
+					if (PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE))
+					{
+						if (msg.message == WM_PAINT) IsDialogMessage(hWnd, &msg);
+						else if (msg.message == WM_LBUTTONDOWN) break;
+					}
+				}
+
+				CloseHandle(hOutfile);
+			}
+
+			faacEncClose(hEncoder);
+		}
+
+		sf_close(infile);
+		MessageBeep(1);
+
+		SendDlgItemMessage(hWnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);
+	} else {
+		MessageBox(hWnd, "Couldn't open input file!", "Error", MB_OK | MB_ICONSTOP);
+	}
+}
+
+static BOOL WINAPI DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	switch (msg)
+	{
+    case WM_INITDIALOG:
+
+		inputFilename [0] = 0x00;
+
+		CheckDlgButton(hWnd, IDC_ALLOWMIDSIDE, TRUE);
+		SetDlgItemText(hWnd, IDC_BITRATE, "64000");
+		SetDlgItemText(hWnd, IDC_BANDWIDTH, "18000");
+
+		DragAcceptFiles(hWnd, TRUE);
+		return TRUE;
+
+    case WM_DROPFILES:
+
+		if (DragQueryFile((HDROP) wParam, 0, (LPSTR) inputFilename, _MAX_PATH - 1))
+			AwakeDialogControls(hWnd);
+		
+		DragFinish((HDROP) wParam);
+		return FALSE;
+
+    case WM_COMMAND:
+
+		switch (wParam)
+		{
+        case IDOK:
+
+			EncodeFile(hWnd);
+			return TRUE;
+
+        case IDCANCEL:
+
+			EndDialog(hWnd, TRUE);
+			return TRUE;
+
+        case IDC_SELECT_INPUTFILE:
+
+			if (SelectFileName(hWnd, inputFilename, TRUE))
+				AwakeDialogControls(hWnd);
+
+			break;
+
+        case IDC_SELECT_OUTPUTFILE:
+
+			if (SelectFileName(hWnd, outputFilename, FALSE))
+			{
+				SetDlgItemText(hWnd, IDC_OUTPUTFILENAME, outputFilename);
+			}
+
+			break;
+		}
+
+		break;
+	}
+
+	return FALSE;
+}
+
+int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+	hInstance = hInst;
+
+	return DialogBox(hInstance, MAKEINTRESOURCE (IDD_MAINDIALOG), NULL, (DLGPROC) DialogProc);
+}
--- /dev/null
+++ b/frontend/resource.h
@@ -1,0 +1,27 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by faacgui.rc
+//
+#define IDD_MAINDIALOG                  102
+#define IDC_INPUTFILENAME               1000
+#define IDC_SELECT_INPUTFILE            1001
+#define IDC_OUTPUTFILENAME              1002
+#define IDC_SELECT_OUTPUTFILE           1003
+#define IDC_INPUTPARAMS                 1004
+#define IDC_OUTPUTFORMAT                1005
+#define IDC_PROGRESS                    1006
+#define IDC_ALLOWMIDSIDE                1007
+#define IDC_TIME                        1008
+#define IDC_BANDWIDTH                   1009
+#define IDC_BITRATE                     1010
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        103
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1016
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
--- a/todo.txt
+++ b/todo.txt
@@ -4,6 +4,7 @@
 
 - DONE: Add frequency cutoff filter
 - DONE: Add ADTS headers
+- DONE: Write GUI
 - Add TNS
 - Add PNS
 - Add LTP
@@ -19,7 +20,6 @@
 - Add Window shape switching
 - Test (and maybe fix) sample rates other than 44100 Hz
 - Test (and maybe fix) multichannel and mono support
-- Write GUI
 - Improve command line tool (wildcards)
 - Write documentation for library interface
 - Speedup?? (no priority)