Commits

Anonymous committed fb21f8e

.wav to .ogg file conversion (requires external tools)

Comments (0)

Files changed (9)

+wav_to_ogg : wav_to_ogg.c
+	cc -O2 -o wav_to_ogg wav_to_ogg.c
+
+clean:
+	-rm -f wav_to_ogg core wav_to_ogg.core
+
+install : wav_to_ogg
+	@cp -v wav_to_ogg /usr/local/bin/
+
+deinstall : uninstall
+uninstall:
+	@rm -v /usr/local/bin/wav_to_ogg
+wav_to_ogg : wav_to_ogg.c
+	cc -O2 -o wav_to_ogg wav_to_ogg.c
+
+clean:
+	-rm -f wav_to_ogg core wav_to_ogg.core
+
+install : wav_to_ogg
+	@cp -v wav_to_ogg /usr/local/bin/
+
+deinstall : uninstall
+uninstall:
+	@rm -v /usr/local/bin/wav_to_ogg
+/*
+  Simple script for WAV to Vorbis conversion via oggenc
+  David Duncan Ross Palmer <www.daybologic.co.uk/mailddrp>
+*/
+
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define QUALITY (5)
+
+static void Help(const char* Program);
+static char* Wavify(const char* FileName);
+static char* myitoa(const int Value);
+
+int main(int argc, char* argv[])
+{
+  int argi;
+  unsigned int count = 0U;
+
+  for ( argi = 1; argi < argc; argi++ ) {
+    if ( strcmp(argv[argi], "--help" ) == 0 ) {
+      Help(argv[0]);
+      break;
+    }
+    else {
+      char command[4096];
+      char* wavified = Wavify(argv[argi]);
+      command[0] = '\0';
+
+      if ( wavified ) {
+        strncat(command, "oggenc -q ", sizeof(command)-1);
+        strncat(command, myitoa(QUALITY), (sizeof(command)-1) - strlen(command));
+        strncat(command, " -o ", (sizeof(command)-1) - strlen(command));
+        strncat(command, wavified, (sizeof(command)-1) - strlen(command));
+        strncat(command, " ", (sizeof(command)-1) - strlen(command));
+        strncat(command, argv[argi], (sizeof(command)-1) - strlen(command));
+        printf("\n\n%s\n", command);
+        system(command);
+        count++;
+        free(wavified);
+      }
+    }
+  }
+  printf("\n%u file(s) converted.\n", count);
+  return EXIT_SUCCESS;
+}
+
+static void Help(const char* Program)
+{
+  printf("%s [--help] [MP3 filenames...]\n", Program);
+}
+
+static char* Wavify(const char* FileName)
+{
+  char* copy = (char*)malloc(strlen(FileName)+16); /* 16 for safely */
+  if ( copy ) {
+    char* ptr;
+    strcpy(copy, FileName);
+    ptr = strrchr(copy, '.');
+    if ( ptr )
+      sprintf(ptr, ".%d.ogg", QUALITY);
+  }
+  return copy;
+}
+
+static char* myitoa(const int Value)
+{
+  static char crappyBuffer[18]; /* Not thread safe, don't copy this function to anywhere else */
+  sprintf(crappyBuffer, "%d", Value);
+  return crappyBuffer;
+}
+/*
+  Simple script for WAV to Vorbis conversion via oggenc
+  David Duncan Ross Palmer <www.daybologic.co.uk/mailddrp>
+*/
+
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define QUALITY (5)
+
+static void Help(const char* Program);
+static char* Wavify(const char* FileName);
+static char* myitoa(const int Value);
+
+int main(int argc, char* argv[])
+{
+  int argi;
+  unsigned int count = 0U;
+
+  for ( argi = 1; argi < argc; argi++ ) {
+    if ( strcmp(argv[argi], "--help" ) == 0 ) {
+      Help(argv[0]);
+      break;
+    }
+    else {
+      char command[4096];
+      char* wavified = Wavify(argv[argi]);
+      command[0] = '\0';
+
+      if ( wavified ) {
+        strncat(command, "oggenc -q ", sizeof(command)-1);
+        strncat(command, myitoa(QUALITY), (sizeof(command)-1) - strlen(command));
+        strncat(command, " -o ", (sizeof(command)-1) - strlen(command));
+        strncat(command, wavified, (sizeof(command)-1) - strlen(command));
+        strncat(command, " ", (sizeof(command)-1) - strlen(command));
+        strncat(command, argv[argi], (sizeof(command)-1) - strlen(command));
+        printf("\n\n%s\n", command);
+        system(command);
+        count++;
+        free(wavified);
+      }
+    }
+  }
+  printf("\n%u file(s) converted.\n", count);
+  return EXIT_SUCCESS;
+}
+
+static void Help(const char* Program)
+{
+  printf("%s [--help] [MP3 filenames...]\n", Program);
+}
+
+static char* Wavify(const char* FileName)
+{
+  char* copy = (char*)malloc(strlen(FileName)+16); /* 16 for safely */
+  if ( copy ) {
+    char* ptr;
+    strcpy(copy, FileName);
+    ptr = strrchr(copy, '.');
+    if ( ptr )
+      sprintf(ptr, ".%d.ogg", QUALITY);
+  }
+  return copy;
+}
+
+static char* myitoa(const int Value)
+{
+  static char crappyBuffer[18]; /* Not thread safe, don't copy this function to anywhere else */
+  sprintf(crappyBuffer, "%d", Value);
+  return crappyBuffer;
+}
+FIL wav_to_ogg.obj
+
+project : h:\work\wav_to_ogg\wavtoogg.exe .SYMBOLIC
+
+!include h:\work\wav_to_ogg\wavtoogg.mk1
+!define BLANK ""
+h:\work\wav_to_ogg\wav_to_ogg.obj : h:\work\wav_to_ogg\wav_to_ogg.c .AUTODEP&
+END
+ @h:
+ cd h:\work\wav_to_ogg
+ *wcc386 wav_to_ogg.c -i=C:\watcom\h;C:\watcom\h\nt -w4 -e25 -zq -od -d2 -5r&
+ -bt=nt -mf
+
+h:\work\wav_to_ogg\wavtoogg.exe : h:\work\wav_to_ogg\wav_to_ogg.obj .AUTODEP&
+END
+ @h:
+ cd h:\work\wav_to_ogg
+ @%write wavtoogg.lk1 FIL wav_to_ogg.obj
+ @%append wavtoogg.lk1 
+!ifneq BLANK ""
+ *wlib -q -n -b wavtoogg.imp 
+ @%append wavtoogg.lk1 LIBR wavtoogg.imp
+!endif
+!ifneq BLANK ""
+ @%append wavtoogg.lk1 op resource=
+!endif
+ *wlink name wavtoogg d all op inc SYS nt op m op maxe=25 op q op symf @wavt&
+oogg.lk1
+
+40
+targetIdent
+0
+MProject
+1
+MComponent
+0
+2
+WString
+4
+NEXE
+3
+WString
+5
+nc2en
+1
+0
+1
+4
+MCommand
+0
+5
+MCommand
+0
+6
+MItem
+12
+wavtoogg.exe
+7
+WString
+4
+NEXE
+8
+WVList
+0
+9
+WVList
+0
+-1
+1
+1
+0
+10
+WPickList
+2
+11
+MItem
+3
+*.c
+12
+WString
+4
+COBJ
+13
+WVList
+0
+14
+WVList
+0
+-1
+1
+1
+0
+15
+MItem
+12
+wav_to_ogg.c
+16
+WString
+4
+COBJ
+17
+WVList
+0
+18
+WVList
+0
+11
+1
+1
+0
+40
+projectIdent
+0
+VpeMain
+1
+WRect
+0
+0
+7680
+9200
+2
+MProject
+3
+MCommand
+0
+4
+MCommand
+0
+1
+5
+WFileName
+12
+wavtoogg.tgt
+6
+WVList
+1
+7
+VComponent
+8
+WRect
+0
+0
+5700
+4293
+0
+0
+9
+WFileName
+12
+wavtoogg.tgt
+0
+1
+7
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.