8 Commits

Author SHA1 Message Date
908ca1d769 stop cpal from crashing on windows! 2021-04-26 22:00:43 +01:00
7db845e03e avoid parsing config file as a sound 2021-04-26 22:00:30 +01:00
fa7361d20f change name of sounds dir function 2021-04-26 21:59:24 +01:00
3aad33189c windows cross-compilation script 2021-04-26 21:58:48 +01:00
6ac967c6d9 try to fix paths for windows 2021-04-26 21:58:11 +01:00
005c90adb0 more sound ideas 2021-04-26 21:57:03 +01:00
5b2688e091 version bump 2021-04-20 10:32:14 +01:00
9f626b8265 remove debug print 2021-04-20 10:31:50 +01:00
4 changed files with 32 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
[package]
name = "lull"
description = "a looping sound player for generating atmospheric soundscapes"
version = "1.0.3"
version = "1.0.4"
authors = ["Max Bradbury <max@tinybird.info>"]
repository = "https://tinybird.dev/max/lull"
license = "MIT"

View File

@@ -10,5 +10,8 @@
* vinyl crackle
* white noise?
* fan
* cat purr
* café
* rustling leaves
* set a window icon
* create a nice icon?

View File

@@ -23,7 +23,8 @@ fn save_config(config: Config) {
let mut config_path = dirs::config_dir()
.expect("Couldn't find user config directory");
config_path.push("ruin/lull");
config_path.push("ruin");
config_path.push("lull");
if !config_path.exists() {
std::fs::create_dir_all(&config_path)
@@ -38,8 +39,6 @@ fn save_config(config: Config) {
let mut config_file = File::create(config_path)
.expect("Couldn't create config file");
print!("{}", toml);
config_file.write(&toml.into_bytes())
.expect("Couldn't write config file");
}
@@ -48,7 +47,9 @@ fn load_config() -> Option<Config> {
let mut config_path = dirs::config_dir()
.expect("Couldn't find user config directory");
config_path.push("ruin/lull/lull.toml");
config_path.push("ruin");
config_path.push("lull");
config_path.push("lull.toml");
let file = File::open(config_path);
@@ -92,10 +93,11 @@ fn error_popup(message: &str) {
popup.show_all();
}
fn get_data_dir() -> PathBuf {
fn get_sounds_dir() -> PathBuf {
let mut data_dir = dirs::data_dir().expect("Couldn't find user data directory");
data_dir.push("ruin/lull");
data_dir.push("ruin");
data_dir.push("lull");
if !data_dir.exists() {
std::fs::create_dir_all(&data_dir).expect("Couldn't create lull data directory");
@@ -121,7 +123,7 @@ fn build_ui(application: &gtk::Application) {
button_manage_sounds.connect_clicked(|_| {
let mut file_manager = Command::new(file_manager());
file_manager.arg(get_data_dir());
file_manager.arg(get_sounds_dir());
file_manager.output().unwrap();
});
@@ -145,7 +147,7 @@ fn build_ui(application: &gtk::Application) {
let device = rodio::default_output_device().unwrap();
let mut paths = std::fs::read_dir(get_data_dir())
let mut paths = std::fs::read_dir(get_sounds_dir())
.expect("Couldn't read lull sounds directory")
.map(|res| res.map(|e| e.path()))
.collect::<Result<Vec<_>, std::io::Error>>()
@@ -154,7 +156,14 @@ fn build_ui(application: &gtk::Application) {
paths.sort();
for path in paths {
let name: &str = path.file_stem().unwrap().to_str().unwrap();
let name = path.file_stem().unwrap().to_str().unwrap();
let extension = path.extension().unwrap().to_str().unwrap();
// on Windows the data dir and config dir are the same,
// so avoid parsing the config file as an audio file
if extension == "toml" {
continue;
}
let file = File::open(&path)
.expect("Couldn't open audio file");
@@ -225,6 +234,10 @@ fn build_ui(application: &gtk::Application) {
}
fn main() {
// instantiate rodio before gtk and don't do anything with it
// this is silly but it's the easiest way to prevent cpal crashing on windows
rodio::default_output_device().unwrap();
let application = gtk::Application::new(
Some("dev.tinybird.max.lull"),
Default::default()

6
windows.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
export PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig
rm -rf package
docker start lull-build-3 -ai | less