Commit e56ce9a2 authored by Romain Beauxis's avatar Romain Beauxis

Imported Upstream version 0.1.0

parents
0.1.0 (2011-06-30)
=====
* Initial release.
This diff is collapsed.
# $Id: Makefile.in 2660 2006-07-18 17:23:31Z dbaelde $
PROGNAME := ocaml-mm
DISTFILES := CHANGES COPYING Makefile.in README \
bootstrap configure configure.ac m4/*.m4 \
src/*.ml src/*.mli src/*.c src/Makefile.in src/META.in \
src/OCamlMakefile src/*.h examples/* external/* config.h.in
VERSION = @VERSION@
all clean install uninstall:
$(MAKE) -C src $@
distclean: clean
$(MAKE) -C examples clean
doc:
$(MAKE) -C src htdoc
mkdir -p doc
rm -rf doc/html
mv src/doc/mm/html doc
rm -rf src/doc
dist: clean
rm -rf $(PROGNAME)-$(VERSION)
mkdir $(PROGNAME)-$(VERSION)
cp -r --parents $(DISTFILES) $(PROGNAME)-$(VERSION)
tar zcvf ../$(PROGNAME)-$(VERSION).tar.gz $(PROGNAME)-$(VERSION)
rm -rf $(PROGNAME)-$(VERSION)
.PHONY: dist doc
ocaml-mm is a library dedicated to performing operations on multimedia
contents. It is designed as a pure ocaml library (ie no dependencies are
required).
Some extensions requiring bindings to various libraries are located in the
external/ directory.
#!/bin/sh
aclocal -I m4
autoheader
autoconf
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* The target is big endian */
#undef BIGENDIAN
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <libavcodec/avcodec.h> header file. */
#undef HAVE_LIBAVCODEC_AVCODEC_H
/* Define to 1 if you have the <linux/videodev.h> header file. */
#undef HAVE_LINUX_VIDEODEV_H
/* Define to 1 if you have the `memalign' function. */
#undef HAVE_MEMALIGN
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/soundcard.h> header file. */
#undef HAVE_SYS_SOUNDCARD_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
This diff is collapsed.
AC_INIT(ocaml-mm, 0.1.0, savonet-users@lists.sourceforge.net)
VERSION=$PACKAGE_VERSION
AC_MSG_RESULT(configuring $PACKAGE_STRING)
AC_PROG_CC()
AC_CHECK_TOOL([AR],[ar],no)
AC_SUBST(AR)
AC_CHECK_OCAML_COMPILERS()
# Include a config.h
AC_CONFIG_HEADERS([config.h:config.h.in])
# Include it
CFLAGS="$CFLAGS -I`pwd`/`dirname $0`"
INCDIRS="$INCDIRS `pwd`/src"
AC_CHECK_FUNCS([memalign])
# Check endianess
AC_C_BIGENDIAN(AC_DEFINE([BIGENDIAN], [1], [The target is big endian]),[])
######### OCaml libs ##########
AC_CHECK_OCAML_PKG([alsa])
INCDIRS="$INCDIRS $OCAML_DIR_alsa"
AC_SUBST(OCAML_HAS_alsa)
AC_CHECK_OCAML_PKG([ao])
INCDIRS="$INCDIRS $OCAML_DIR_ao"
AC_SUBST(OCAML_HAS_ao)
AC_CHECK_OCAML_PKG([gstreamer])
INCDIRS="$INCDIRS $OCAML_DIR_gstreamer"
AC_SUBST(OCAML_HAS_gstreamer)
AC_CHECK_OCAML_PKG([mad])
INCDIRS="$INCDIRS $OCAML_DIR_mad"
AC_SUBST(OCAML_HAS_mad)
AC_CHECK_OCAML_PKG([ogg])
INCDIRS="$INCDIRS $OCAML_DIR_ogg"
AC_SUBST(OCAML_HAS_ogg)
AC_CHECK_OCAML_PKG([sdl])
INCDIRS="$INCDIRS $OCAML_DIR_sdl"
AC_SUBST(OCAML_HAS_sdl)
AC_CHECK_OCAML_PKG([theora])
INCDIRS="$INCDIRS $OCAML_DIR_theora"
AC_SUBST(OCAML_HAS_theora)
########## OSS ##########
AC_ARG_ENABLE([oss],AC_HELP_STRING([--disable-oss],["don't use OSS"]))
if test "x$enable_oss" != "xno" ; then
AC_CHECK_HEADERS([sys/soundcard.h],[W_OSS="yes"],[W_OSS="no"])
fi
AC_SUBST(W_OSS)
########## FFmpeg ##########
AC_ARG_ENABLE([ffmpeg],AC_HELP_STRING([--disable-ffmpeg],["don't use FFmpeg"]))
if test "x$enable_ffmpeg" != "xno" ; then
AC_CHECK_HEADERS([libavcodec/avcodec.h],[W_FFMPEG="yes"],[W_FFMPEG="no"])
fi
AC_SUBST(W_FFMPEG)
########## v4l ##########
AC_ARG_ENABLE([v4l],AC_HELP_STRING([--disable-v4l],["don't use video4linux"]))
if test "x$enable_v4l" != "xno" ; then
AC_CHECK_HEADERS([linux/videodev.h],[W_V4L="yes"],[W_V4L="no"])
fi
AC_SUBST(W_V4L)
AC_SUBST(VERSION)
AC_SUBST(INCDIRS)
# Finally create the Makefile
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile],[chmod a-w src/Makefile])
AC_CONFIG_FILES([external/Makefile],[chmod a-w external/Makefile])
AC_CONFIG_FILES([external/Makefile.defs],[chmod a-w external/Makefile.defs])
AC_CONFIG_FILES([src/META])
AC_OUTPUT
cat <<EOMSG
Supported external libraries:
- Alsa : $OCAML_HAS_alsa
- AO : $OCAML_HAS_ao
- FFmpeg : $W_FFMPEG
- Gstreamer : $OCAML_HAS_gstreamer
- Mad : $OCAML_HAS_mad
- ogg : $OCAML_HAS_ogg
- OSS : $W_OSS
- SDL : $OCAML_HAS_sdl
- Theora : $OCAML_HAS_theora
- V4L : $W_V4L
EOMSG
EXAMPLES = $(shell find . -maxdepth 1 -type d | sed "s/^\.\///" | grep -v "\.")
all clean doc:
for d in $(EXAMPLES); do $(MAKE) -C $$d $@; done
.PHONY: all
\ No newline at end of file
This diff is collapsed.
SOURCES = autotune.ml
RESULT = autotune
INCDIRS = ../../src ../../external/alsa +alsa
LIBS = unix bigarray mm alsa mm.alsa
OCAMLFLAGS = -g
test: all
OCAMLRUNPARAM=b ./autotune
all: dnc
include OCamlMakefile
../OCamlMakefile
\ No newline at end of file
module FFT = Audio.Mono.Analyze.FFT
let channels = 2
let sample_rate = 44100
let periods = 4
let () =
let fft = FFT.init 11 in
let blen = FFT.duration fft in
let alsa_in = MMAlsa.rw channels sample_rate ~capture:true ~buffer_size:(periods*blen) ~periods () in
let alsa_out = MMAlsa.rw channels sample_rate ~playback:true ~blocking:false ~buffer_size:(periods*blen) ~periods () in
let buf = Audio.create channels blen in
(* let agc = Audio.Effect.auto_gain_control channels sample_rate ~rms_target:2. () in *)
let gen = new Audio.Generator.of_mono (new Audio.Mono.Generator.saw sample_rate 440.) in
let loop = ref true in
Printf.printf "Using Alsa %s (delay: %d samples).\n" alsa_out#version alsa_out#delay;
(* alsa#prepare; *)
while !loop do
(* gen#fill buf 0 blen; *)
(
try
assert (alsa_out#wait 1000);
let w = alsa_out#write buf 0 blen in
Printf.printf "Wrote: %d\n%!" w
with
| Alsa.Buffer_xrun as e ->
alsa_out#recover e;
ignore (alsa_out#write buf 0 blen)
);
let r = alsa_in#read buf 0 blen in
(* Printf.printf "Read: %d\n%!" r *) ()
done;
alsa_in#close;
alsa_out#close
SOURCES = dictee.ml
RESULT = dictee
INCDIRS = ../../src ../../external/oss ../../external/mad
LIBS = unix bigarray mad mm mm.oss mm.mad
OCAMLFLAGS = -g
test: all
OCAMLRUNPARAM=b ./dictee ../test.mp3
all: dnc
include OCamlMakefile
include ../../external/Makefile.defs
../OCamlMakefile
\ No newline at end of file
module FFT = Audio.Mono.Analyze.FFT
let polyphony = 1
let mchan = 0
let oss_out = true
let list_diff cmp l1 l2 =
List.fold_left
(fun acc x ->
if not (List.exists (cmp x) l2) then
x::acc
else
acc
) [] l1
let rec list_head_n n l =
if n = 0 then
[]
else
match l with
| h::t -> h::(list_head_n (n-1) t)
| [] -> []
let () =
let fname = Sys.argv.(1) in
let f = new MMMad.reader_of_file fname in
let oss = new MMOSS.writer f#channels f#sample_rate in
let wav = new Audio.IO.Writer.to_wav_file f#channels f#sample_rate "out.wav" in
let mid = new MIDI.IO.Writer.to_file f#sample_rate "out.mid" in
let fft_n = 11 in
let fft = FFT.init fft_n in
let blen = FFT.duration fft in
let buf = Audio.create f#channels blen in
let agc = Audio.Effect.auto_gain_control f#channels f#sample_rate ~kup:0.9 ~kdown:0.7 ~rms_target:2. () in
let adsr = Audio.Mono.Effect.ADSR.make f#sample_rate (0.02,0.01,0.9,0.05) in
let synth = new Synth.saw ~adsr f#sample_rate in
let loop = ref true in
let prevnotes = ref [] in
synth#set_volume 0.1;
while !loop do
let r = f#read buf 0 blen in
agc#process buf 0 blen;
loop := r <> 0;
let notes = FFT.notes f#sample_rate fft ~note_min:(Audio.Note.create 0 4) ~volume_min:0.01 ~filter_harmonics:false (Audio.to_mono buf) 0 blen in
let notes = List.sort (fun (_,v1) (_,v2) -> if v1 < v2 then 1 else -1) notes in
let notes = list_head_n polyphony notes in
(* Printf.printf "Notes: %d\n%!" (List.length notes); *)
let ncmp (n1,_) (n2,_) = n1 = n2 in
List.iter (fun (n,v) -> synth#note_off n 1.; mid#note_off mchan n (10. *. v)) (list_diff ncmp !prevnotes notes);
List.iter (fun (n,v) -> synth#note_on n 1.; mid#note_on mchan n (10. *. v)) (list_diff ncmp notes !prevnotes);
prevnotes := notes;
synth#fill_add buf 0 blen;
mid#advance blen;
Audio.amplify 2. buf 0 blen;
wav#write buf 0 blen;
if oss_out then
oss#write buf 0 blen
done;
wav#close;
mid#close;
oss#close;
f#close
SOURCES = display.ml
RESULT = display
INCDIRS = ../../src
LIBS = str unix bigarray mm graphics
test: all
OCAMLRUNPARAM=b ./display ../test.ppm
all: pnc
include OCamlMakefile
../OCamlMakefile
\ No newline at end of file
module Img = Image.RGBA32
let read_PPM ?alpha fname =
let ic = open_in_bin fname in
let len = in_channel_length ic in
let data = String.create len in
really_input ic data 0 len;
close_in ic;
Img.of_PPM ?alpha data
let () =
let fname = Sys.argv.(1) in
let img = read_PPM fname in
(* let img = Img.Scale.create ~kind:Img.Scale.Bilinear img 500 500 in *)
let w,h = Img.dimensions img in
Graphics.open_graph "";
Graphics.resize_window w h;
Graphics.draw_image (Graphics.make_image (Img.to_int_image img)) 0 0;
ignore (Graphics.wait_next_event [Graphics.Key_pressed])
SOURCES = drums.ml
RESULT = drums
INCDIRS = ../../src ../../external/oss ../../external/sdl +sdl
LIBS = unix bigarray mm mm.oss sdl mm.sdl
test: all
./drums
all: nc
include OCamlMakefile
../OCamlMakefile
\ No newline at end of file
let sample_rate = 44100
let channels = 2
let sd freq v =
let lpf = new Audio.Mono.Effect.biquad_filter sample_rate `Low_pass (freq*.5.) 2. in
let adsr = Audio.Mono.Effect.ADSR.make sample_rate (0., 0.25, 0., 1.) in
let g = new Audio.Mono.Generator.white_noise sample_rate in
let g = new Audio.Mono.Generator.chain g lpf in
let g = new Audio.Mono.Generator.adsr adsr g in
let g = new Audio.Generator.of_mono g in
g
let bd freq v =
let lpf = new Audio.Mono.Effect.biquad_filter sample_rate `Low_pass (freq *. 1.) 2. in
let adsr = Audio.Mono.Effect.ADSR.make sample_rate (0.001, 0.3, 0., 1.) in
let g = new Audio.Mono.Generator.sine sample_rate 80. in
let g2 = new Audio.Mono.Generator.sine sample_rate 90. in
let g = new Audio.Mono.Generator.mult g g2 in
let g2 = new Audio.Mono.Generator.white_noise ~volume:0.5 sample_rate in
let g = new Audio.Mono.Generator.add g g2 in
let g = new Audio.Mono.Generator.chain g lpf in
let g = new Audio.Mono.Generator.adsr adsr g in
let g = new Audio.Mono.Generator.chain g (new Audio.Mono.Effect.clip 0.9) in
let g = new Audio.Mono.Generator.chain g (new Audio.Mono.Effect.amplify 5.) in
let g = new Audio.Generator.of_mono g in
g
let blen = sample_rate / 3
let no = Audio.create channels blen
let gen i =
let buf = Audio.create channels blen in
(i 440. 1.)#fill buf 0 blen;
buf
let bd = gen bd
let sd = gen sd
let () =
let oss = new MMOSS.writer channels sample_rate in
(* let wav = new Audio.IO.Writer.to_wav_file channels sample_rate "out.wav" in *)
(* let buf = Audio.create channels blen in *)
(* let mbuf = MIDI.create blen in *)
(* let synth_sd = new Synth.create sd in *)
(* let keybd = new MMSDL.midi_keyboard in *)
(* MIDI.insert mbuf (0, MIDI.Note_on (MIDI.note_of_name "a4", 1.)); *)
(* keybd#read sample_rate [|mbuf|] 0 blen; *)
(* synth_sd#play mbuf 0 buf 0 blen; *)
let buf = Audio.append bd sd in
while true do
(* wav#write buf 0 blen; *)
oss#write buf 0 (Audio.duration buf)
done;
(* wav#close; *)
oss#close
SOURCES = player.ml
RESULT = player
OCAMLFLAGS = -g
INCDIRS = ../../src ../../external/ffmpeg ../../external/sdl +sdl
LIBS = str unix bigarray graphics mm mm.ffmpeg sdl mm.sdl
test: dnc
OCAMLRUNPARAM=b ./player ../test.mov
all: nc
prof:
$(MAKE) clean pnc test
gprof ./player > prof
head -n 20 prof
gdb: dnc
gdb --args ./player ../test.mov
valgrind: dnc
valgrind ./player ../test.mov
include OCamlMakefile
.PHONY: prof
../OCamlMakefile
\ No newline at end of file
let vidbuflen = 1
let width = 1024/2
let height = 600/2
let () = MMSDL.init ()
let () =
let fname = Sys.argv.(1) in
let f = new MMFFmpeg.reader_of_file fname in
let sdl = new MMSDL.writer_to_screen width height in
let out = new MMFFmpeg.writer_to_file "out.avi" f#frame_rate width height 4000000 in
let vid = Video.create vidbuflen in
let loop = ref true in
let tot = ref 0 in
(* f#set_target_size width height; *)
(*
Graphics.open_graph "";
Graphics.resize_window width height;
*)
while !loop do
let r = f#read vid 0 vidbuflen in
tot := !tot + r;
(* Printf.printf "got: %d\n%!" !tot; *)
if r = 0 then loop := false;
Printf.printf "out: %d\n%!" !tot;
Video.map_all
vid
(fun f ->
let img = Image.RGBA32.create width height in
Image.RGBA32.Scale.onto f img;
img
);
(* Video.iter_all vid Image.RGBA32.Effect.invert; *)
out#write vid 0 r;
sdl#write vid 0 r;
(* if !tot >= 200 then
(
Printf.printf "CLOSE\n%!";
out#close;
exit 0
); *)
(*
let img = vid.(0) in
let img = Image.RGBA32.to_int_image img in
let img = Graphics.make_image img in
Graphics.draw_image img 0 0;
*)
done;
out#close;
sdl#close;
f#close
SOURCES = gui.glade player.ml
RESULT = player
OCAMLFLAGS = -g
INCDIRS = ../../src ../../external/ffmpeg +lablgtk2
LIBS = str bigarray graphics mm mm.ffmpeg lablglade
THREADS = yes
OCAMLBLDFLAGS = lablgtk.cma gtkInit.cmo gtkThread.cmo
OCAMLNLDFLAGS = lablgtk.cmxa gtkInit.cmx gtkThread.cmx
test: dnc
OCAMLRUNPARAM=b ./player ../test.mov
include OCamlMakefile
\ No newline at end of file
../OCamlMakefile
\ No newline at end of file
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window">
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem1">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem3">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem4">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menu_quit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu2">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="imagemenuitem6">
<property name="label">gtk-cut</property>