# fmedia v1.26 configuration


# Maximum number of worker threads
# 0: use all CPUs
workers 0

# codepage for non-Unicode text: win1251 | win1252
codepage win1252

# single instance mode for fmedia-gui:
# . off: allow multiple instances
# . add: add files to the currently active queue
# . play: add files and start playback of the first added track
# . clear_play: clear the active queue, add files and start playback
instance_mode play

# Don't allow the system to put itself to sleep after some time of inactivity
prevent_sleep true
mod "#winsleep.sleep"
mod "dbus.sleep"

# Store user configuration files inside fmedia directory.
# If this option is "false", user configuration files are stored inside "%APPDATA%\fmedia" (Windows) or "$HOME/.config/fmedia" (Linux) directory.
portable_conf false

mod_conf "#globcmd.globcmd" {
	pipe_name fmedia
}

mod_conf "#file.in" {
	buffer_size 64k
	buffers 3
	# align 4k

	# Offload read operations to another thread
	use_thread_pool true

	# Read from file using the system's asynchronous I/O
	direct_io false
}

mod_conf "#file.out" {
	buffer_size 64k
	preallocate 1m

	# Offload write operations to another thread
	# Asynchronous writing may help utilizing more CPU resources
	use_thread_pool true
}

mod "#file.stdin"
mod_conf "#file.stdout" {
	buffer_size 64k
}

mod "mixer.in"

mod_conf "afilter.mixer-out" {
	format int16
	channels 2
	rate 44100

	# buffer size (in msec)
	buffer 1000
}

mod "afilter.autoconv"
mod "afilter.conv"
mod "afilter.gain"
mod "afilter.until"
mod "afilter.silgen"
mod "afilter.startlevel"
mod "afilter.stoplevel"
mod "afilter.membuf"
mod "afilter.peaks"
mod "afilter.split"

mod "afilter.auto-attenuator"

# analyze PCM peaks in real-time
mod "afilter.rtpeak"

mod_conf "#queue.track" {
	# Start the next track in list after an error has occurred with the current track
	next_if_error true
}

mod "soxr.conv"

# Dynamic Audio Normalizer
mod_conf "dynanorm.filter" {
	# frame_len_msec 0
	# filter_size 0
	# peak_value 0
	# max_amplification 0
	# target_rms 0
	# compress_factor 0
	# channels_coupled 0
	# enable_dc_correction 0
	# alt_boundary_mode 0
}

mod_conf "plist.dir" {
	# Expand sub-directories
	expand true
}

mod "plist.m3u"
mod "plist.pls"
mod "plist.cue"
mod "plist.cuehook"
mod "plist.m3u-out"

mod "fmt.edit-tags"


# UI:

mod_conf "tui.tui" {
	# Disable terminal input echo on Linux.
	# Set to "false" if you experience problems when terminal echo isn't restored after fmedia process was killed.
	echo_off true

	# "Delete From Disk" job:
	# . default: move to trash
	# . rename: rename a file to ".deleted"
	file_delete_method default
}

mod "gui.rec-nfy"


# CONTAINERS:

mod "fmt.mp4"
mod "fmt.mp4-write"
mod "fmt.avi"
mod "fmt.mkv"

mod_conf "fmt.ogg" {
	seekable true
}

mod_conf "fmt.ogg-write" {
	# Maximum page duration (in msec)
	max_page_duration 1000
}

mod "fmt.aac"
mod "fmt.aac-write"


# AUDIO CODECS:

mod "fmt.wav"
mod "fmt.raw"
mod "fmt.wav-write"
mod "fmt.ape"
mod "fmt.wv"

mod "fmt.mp3"
mod "mpeg.decode"

mod_conf "mpeg.encode" {
	# VBR quality: 9..0 or CBR bitrate: 64..320
	quality 2
}

mod_conf "fmt.mp3-write" {
	min_meta_size 1000
}

mod "fmt.mp3-copy"

mod "fmt.mpc"
mod "mpc.decode"

mod "vorbis.decode"

mod_conf "vorbis.encode" {
	# minimum size of Vorbis comments (add padding if necessary)
	min_tag_size 1000

	# -1.0 .. 10.0
	quality "5.0"
}

mod "opus.decode"

mod_conf "opus.encode" {
	# Minimum size of Vorbis comments (add padding if necessary)
	min_tag_size 1000

	bitrate 192

	# (in msec)
	frame_size 40

	# 0..10
	# complexity 10

	# (in kHz)
	# bandwidth 20
}

mod "flac.decode"

mod_conf "flac.encode" {
	# compression level: 0..8
	compression 6

	# generate MD5 checksum of uncompressed data
	md5 true
}

mod "flac.in"
mod "flac.ogg-in"

mod_conf "flac.out" {
	# audio interval (in seconds) for seek table (0=disable)
	seektable_interval 1

	# minimum size of meta data (add padding block if needed)
	min_meta_size 1000
}

mod "fmt.caf"

mod "alac.decode"

mod "aac.decode"

mod_conf "aac.encode" {
	# LC | HE | HEv2
	profile LC

	# AAC encoding quality: 1..5 (VBR) or 8..800 (CBR, kbit/s)
	quality 256

	# Better quality at the cost of additional encoding time
	afterburner 1

	# Frequency cut-off (max. 20000Hz);  0: default setting.
	bandwidth 0
}

mod "wavpack.decode"

mod "ape.decode"


# AUDIO I/O:

mod_conf "wasapi.out" {
	device_index 0
	exclusive_mode 0
	buffer_length 500
}

mod_conf "wasapi.in" {
	device_index 0

	# 0: disabled, 1: allowed, 2: always
	exclusive_mode 0

	# in msec
	buffer_length 100

	latency_autocorrect false
}

mod_conf "direct-sound.in" {
	device_index 0
	buffer_length 500
}

mod_conf "direct-sound.out" {
	device_index 0
	buffer_length 500
}


mod_conf "alsa.out" {
	device_index 0
	buffer_length 500
	notify_rate 0
}

mod_conf "alsa.in" {
	device_index 0
	buffer_length 500
}


mod_conf "pulse.out" {
	device_index 0
	buffer_length 250
	notify_rate 0
}

mod "pulse.in"


mod "jack.in"


mod "oss.in"


mod_conf "coreaudio.out" {
	device_index 0
}

mod_conf "coreaudio.in" {
	device_index 0
	buffer_length 1000
}


mod_conf "oss.out" {
	device_index 0
	# buffer_length 500
}


# Module for audio playback

# Windows:
output "wasapi.out"
# output "direct-sound.out"

# Linux:
output_optional "pulse.out"
output "alsa.out"

# FreeBSD:
output "oss.out"

# macOS:
output "coreaudio.out"


# Module for audio recording

# Windows:
input "wasapi.in"
# input "direct-sound.in"

# Linux:
input "alsa.in"
# input "pulse.in"
# input "jack.in"

# FreeBSD:
input "oss.in"

# macOS:
input "coreaudio.in"

# Default audio format for recording
record_format {
	# Audio format: int8 | int16 | int24 | int32 | float32
	format int16
	# Channels number: 2 (stereo) | 1 (mono) | left | right
	channels 2
	rate 44100
}


input_ext {
	# mod ext...
	"fmt.wav" wav
	"fmt.raw" raw
	"fmt.mp3" mp3
	"fmt.mpc" mpc
	"fmt.aac" aac
	"flac.in" flac
	"fmt.caf" caf
	"fmt.wv" wv
	"fmt.ape" ape

	"fmt.avi" avi
	"fmt.mkv" mka mkv
	"fmt.mp4" m4a mp4
	"fmt.ogg" ogg opus

	"plist.m3u" m3u m3u8
	"plist.pls" pls
	"plist.cue" cue
}

output_ext {
	# mod ext...
	"fmt.wav-write" wav
	"fmt.ogg-write" ogg opus
	"fmt.mp4-write" m4a
	"fmt.mp3-write" mp3
	"fmt.aac-write" aac
	"flac.out" flac

	"plist.m3u-out" m3u m3u8
}


# Additional configuration files:
include "fmedia-ext.conf"

# Per-user configuration:
#  Portable mode: "./fmedia-user.conf"
#  Windows: %APPDATA%/fmedia/fmedia-user.conf
#  Linux:   $HOME/.config/fmedia/fmedia-user.conf
include_user "fmedia-user.conf"
