diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2017-01-12 10:15:23 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2017-01-12 10:15:23 +0200 |
commit | 58eb60171cf3d58aec043a4d05830af720f5eb52 (patch) | |
tree | bf735b2f7e1af9c843634c377c07577d291a170c | |
parent | 8342ef131441f4b7d0b00f200e6353fb7cf26527 (diff) |
Started refactoring gui creation to include drawing area
The drawing area will eventually be used for a debugging graph of the
frequency spectrum.
-rw-r--r-- | Cargo.lock | 220 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/gui.rs | 138 | ||||
-rw-r--r-- | src/lib.rs | 2 |
4 files changed, 194 insertions, 170 deletions
@@ -2,21 +2,21 @@ name = "rusty_microphone" version = "0.1.0" dependencies = [ + "cairo-rs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "dft 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gtk 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "portaudio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "atk-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -42,21 +42,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cairo-rs" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_vec 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cairo-sys-rs" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -70,159 +70,159 @@ dependencies = [ [[package]] name = "gdk" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gio 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gdk-pixbuf" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gdk-pixbuf-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gdk-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gio" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gio-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "glib" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gio-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "glib-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gobject-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gtk" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gio 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gtk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gtk-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "atk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -267,23 +267,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pango" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "glib 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pango-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -298,38 +298,38 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum atk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52dba8b14510e6d21395f6176396993782f8d1097a7b56bda448213a745311fd" +"checksum atk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3dd4937c8c40a0b5184d7810772d44cd3d4afdca711b8878c7f14b3f8ef80f" "checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" "checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum c_vec 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9e1d9f7d49e289f36f19effbf3d5a5e30163ecf9c7a3c9be94d5374dec5b9a" -"checksum cairo-rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7897ceda29077c3d87f2d46a0f23ed6c552e48e8d1943ac755f8956f81a8a20d" -"checksum cairo-sys-rs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e43dcd461d0b014b01443cbda24684e88060e462a757a732e30309bb5fa26c9e" +"checksum cairo-rs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3e2dae876fba33394353e985bff24e011a18250cf0021d07b86900b77388b0" +"checksum cairo-sys-rs 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e377d5ccba12485dbdd1d459d711b948bbbed867f5808b25e0e2f6c8a45935f6" "checksum dft 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3883b2ea3b807bcb59f1edfc2170ee82203e324739a80a30274e07a242a27ad2" -"checksum gdk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dbdd6a10d03581c2de537ad016f33522476091c05094ad9cf2e284985eb7d208" -"checksum gdk-pixbuf 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c4fd94e8cb37a8e25f84dd18b574a5d54823da3e8a9fe9b0adc154c77ca5c98" -"checksum gdk-pixbuf-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4db256fec7cfbb3ec00e45096a67b676dc255d5cdeb10770b8f0137932ec0944" -"checksum gdk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dce70d89e26b1b97a9ea580ef1f9d08a75b8623627a8452821c9357fc57fafbe" -"checksum gio 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7ac814c79b301903e2f43428d26497c5d58fc1f34f4376d6f8a12bb296612a47" -"checksum gio-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f858f0e536ce876868583a3a8df1025832d76567897da7f8ad860851eff3" -"checksum glib 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf2e0735d142ea9c5f29b1df3cfe1f818be83acd5f639a4c5516c70807574b53" -"checksum glib-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "512bc05befa05ae5fa84470205bae44d60c2209d95921d1a605e96f2f6578ac7" -"checksum gobject-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70a2806ba2978a5072660797bc76c06ebf1b29dd7f857c6b485ac33423677529" -"checksum gtk 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4d3d0f046cb1473bfe9e6fbcc8478a5cbab07cfb21495734a37c9d8cd463dc7" -"checksum gtk-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91d0e8c624c3b4e8047b960b350b208c82e2eb0d4e3db5da9a55590c10f2616d" -"checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" +"checksum gdk 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "151196bd3a35bc157b7dca6ee98bb701dca59439dedd19d8a85b2d8759e0afaf" +"checksum gdk-pixbuf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f893bde751ef13bae431c5643021d0b9365b5455ab6b2febbc492bbe431d573b" +"checksum gdk-pixbuf-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f04793815a1e18b12de3b5bf41820c64ff84323510ecf3261a7f329eccd59500" +"checksum gdk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0f372ea49640676521a6591a6d49987f442095a862799429fc129b1fdcf91716" +"checksum gio 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "734791445c09c47176d456457da457703e5297ce93ae088924fed7cb98b49663" +"checksum gio-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0b0e02a42941ed54bf56ac179693469a37abe118d9ce710669d8c1b6391c79" +"checksum glib 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4beb06ab666c546a921d93e6550e5ceb3fa7a8f9450920792144543489c1bb1" +"checksum glib-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a315f2df997f0ca1e3ebf1a78b5c6e455a7d75b8da8891ddf77068bf3d7492b3" +"checksum gobject-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88376c229e515b770f6ae56c5460a52cbc24ba4e81fd9a4c0a65900335241e8f" +"checksum gtk 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "50c5d2d3330a4d92348bbe5e2346fbeb31384af1d547c0ad7c120639d8c19718" +"checksum gtk-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ecdca043a321a1c19a16ae0efb9fcab6922051711fe238413b80f301e9caf17d" +"checksum libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9e030dc72013ed68994d1b2cbf36a94dd0e58418ba949c4b0db7eeb70a7a6352" "checksum num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "bde7c03b09e7c6a301ee81f6ddf66d7a28ec305699e3d3b056d2fc56470e3120" "checksum num-complex 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c78e054dd19c3fd03419ade63fa661e9c49bb890ce3beb4eee5b7baf93f92f" "checksum num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "fb24d9bfb3f222010df27995441ded1e954f8f69cd35021f6bef02ca9552fb92" "checksum num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "287a1c9969a847055e1122ec0ea7a5c5d6f72aad97934e131c83d5c08ab4e45c" "checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c" -"checksum pango 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9163a579a31a3a07023f8ac47a27b62d3f59fae058f37993ec2815afaeb6d4d9" -"checksum pango-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d4e9d57dc8bb3a28b59d9339b13f67c456238921d82c3ae8eefd1ac815247b" +"checksum pango 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d25afdf2915e8afee5d0c2fccd8426b7c32e3a58aaf7ed2b41a4609c64617de" +"checksum pango-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a894abf6d9c35d205137cecc9e06e500b145f8381a4a700b2036aaa4fe8b6874" "checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa" "checksum portaudio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d289315f6155a7608b6d8757786c79ed2243afeab8a5eda8989effda3fdc5c3" @@ -6,8 +6,8 @@ authors = ["Justin Worthe <justin.worthe@gmail.com>"] [dependencies] portaudio = "0.7.0" dft = "0.4.3" -gdk = "0.5.0" +cairo-rs = "0.1.1" [dependencies.gtk] -version = "0.1.0" +version = "0.1.1" features = ["v3_10"]
\ No newline at end of file @@ -8,26 +8,12 @@ use std::io::Write; use std::thread; use std::sync::mpsc::*; -const GUI_XML: &'static str = r#" -<interface> - <object class="GtkWindow" id="window"> - <property name="title">Rusty Microphone</property> - <child> - <object class="GtkVBox"> - <child> - <object class="GtkComboBoxText" id="dropdown"> - </object> - </child> - <child> - <object class="GtkLabel" id="pitch-label"> - <property name="label">Hello world</property> - </object> - </child> - </object> - </child> - </object> -</interface> -"#; +struct RustyUi { + window: gtk::Window, + dropdown: gtk::ComboBoxText, + pitch_label: gtk::Label, + freq_chart: gtk::DrawingArea +} struct ApplicationState { pa: pa::PortAudio, @@ -46,55 +32,52 @@ pub fn start_gui() -> Result<(), String> { try!(gtk::init().map_err(|_| "Failed to initialize GTK.")); - let gtk_builder = try!(create_window(microphones)); + let ui = create_window(microphones); - connect_dropdown_choose_microphone(>k_builder, mic_sender, state.clone()); + connect_dropdown_choose_microphone(&ui.dropdown, mic_sender, state.clone()); let (pitch_sender, pitch_receiver) = channel(); + let (freq_sender, freq_receiver) = channel(); - start_processing_audio(mic_receiver, pitch_sender); - - let pitch_label: gtk::Label = gtk_builder.get_object("pitch-label").expect("GUI does not contain an object with id 'pitch-label'"); - gtk::timeout_add(100, move || { - let mut pitch = None; - loop { - let next = pitch_receiver.try_recv().ok(); - if next.is_none() { - break; - } - pitch = next; - } - match pitch { - Some(pitch) => {pitch_label.set_label(pitch.as_ref());}, - None => {} - }; - gtk::Continue(true) - }); + start_processing_audio(mic_receiver, pitch_sender, freq_sender); + + setup_pitch_label_callbacks(ui.pitch_label, pitch_receiver); + setup_drawing_area_callbacks(ui.freq_chart, freq_receiver); gtk::main(); Ok(()) } -fn create_window(microphones: Vec<(u32, String)>) -> Result<gtk::Builder, String> { - let gtk_builder = gtk::Builder::new_from_string(GUI_XML); - let window: gtk::Window = try!( - gtk_builder.get_object("window") - .ok_or("GUI does not contain an object with id 'window'") - ); - window.set_default_size(300, 300); +fn create_window(microphones: Vec<(u32, String)>) -> RustyUi { + let window = gtk::Window::new(gtk::WindowType::Toplevel); + window.set_title("Rusty Microphone"); window.connect_delete_event(|_, _| { gtk::main_quit(); Inhibit(false) }); - window.show_all(); - let dropdown: gtk::ComboBoxText = try!( - gtk_builder.get_object("dropdown") - .ok_or("GUI does not contain an object with id 'dropdown'") - ); + let layout_box = gtk::Box::new(gtk::Orientation::Vertical, 5); + window.add(&layout_box); + + let dropdown = gtk::ComboBoxText::new(); set_dropdown_items(&dropdown, microphones); + layout_box.add(&dropdown); + + let pitch_label = gtk::Label::new(None); + layout_box.add(&pitch_label); - Ok(gtk_builder) + let freq_chart = gtk::DrawingArea::new(); + freq_chart.set_size_request(600, 400); + layout_box.add(&freq_chart); + + window.show_all(); + + RustyUi { + window: window, + dropdown: dropdown, + pitch_label: pitch_label, + freq_chart: freq_chart + } } fn set_dropdown_items(dropdown: >k::ComboBoxText, microphones: Vec<(u32, String)>) { @@ -103,14 +86,16 @@ fn set_dropdown_items(dropdown: >k::ComboBoxText, microphones: Vec<(u32, Strin } } -fn connect_dropdown_choose_microphone(gtk_builder: >k::Builder, mic_sender: Sender<Vec<f64>>, state: Rc<RefCell<ApplicationState>>) { - let dropdown: gtk::ComboBoxText = gtk_builder.get_object("dropdown").expect("GUI does not contain an object with id 'dropdown'"); +fn connect_dropdown_choose_microphone(dropdown: >k::ComboBoxText, mic_sender: Sender<Vec<f64>>, state: Rc<RefCell<ApplicationState>>) { dropdown.connect_changed(move |dropdown: >k::ComboBoxText| { match state.borrow_mut().pa_stream { Some(ref mut stream) => {stream.stop().ok();}, _ => {} } - let selected_mic = dropdown.get_active_id().and_then(|id| id.parse().ok()).expect("Dropdown did not change to a valid value"); + let selected_mic = match dropdown.get_active_id().and_then(|id| id.parse().ok()) { + Some(mic) => mic, + None => {return;} + }; let stream = ::audio::start_listening(&state.borrow().pa, selected_mic, mic_sender.clone()).ok(); if stream.is_none() { writeln!(io::stderr(), "Failed to open audio channel").ok(); @@ -119,10 +104,11 @@ fn connect_dropdown_choose_microphone(gtk_builder: >k::Builder, mic_sender: Se }); } -fn start_processing_audio(mic_receiver: Receiver<Vec<f64>>, pitch_sender: Sender<String>) { +fn start_processing_audio(mic_receiver: Receiver<Vec<f64>>, pitch_sender: Sender<String>, freq_sender: Sender<Vec<::transforms::FrequencyBucket>>) { thread::spawn(move || { for samples in mic_receiver { let frequency_domain = ::transforms::fft(samples, 44100.0); + freq_sender.send(frequency_domain.clone()); let fundamental = ::transforms::find_fundamental_frequency(&frequency_domain); let pitch = match fundamental { Some(fundamental) => ::transforms::hz_to_pitch(fundamental), @@ -132,3 +118,41 @@ fn start_processing_audio(mic_receiver: Receiver<Vec<f64>>, pitch_sender: Sender } }); } + +fn setup_pitch_label_callbacks(pitch_label: gtk::Label, pitch_receiver: Receiver<String>) { + gtk::timeout_add(100, move || { + let mut pitch = None; + loop { + let next = pitch_receiver.try_recv().ok(); + if next.is_none() { + break; + } + pitch = next; + } + match pitch { + Some(pitch) => {pitch_label.set_label(pitch.as_ref());}, + None => {} + }; + gtk::Continue(true) + }); +} + +fn setup_drawing_area_callbacks(canvas: gtk::DrawingArea, freq_receiver: Receiver<Vec<::transforms::FrequencyBucket>>) { + canvas.connect_draw(move |ref canvas, ref context| { + let mut last_signal = Vec::new(); + loop { + let next = freq_receiver.try_recv().ok(); + if next.is_none() { + break; + } + last_signal = next.unwrap(); + } + + context.new_path(); + context.move_to(0.0, 0.0); + context.line_to(canvas.get_allocated_width() as f64, canvas.get_allocated_height() as f64); + context.stroke(); + + gtk::Inhibit(false) + }); +} @@ -1,5 +1,5 @@ extern crate gtk; -extern crate gdk; +extern crate cairo; extern crate portaudio; pub mod transforms; |