Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linux support #27

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Concentus.Oggfile/Concentus.Oggfile.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Concentus.Oggfile</RootNamespace>
<AssemblyName>Concentus.Oggfile</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
Expand Down
2 changes: 1 addition & 1 deletion Concentus/Concentus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Concentus</RootNamespace>
<AssemblyName>Concentus</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
Expand Down
22 changes: 22 additions & 0 deletions Linux/TeddyBench
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# check for mono
if ! type "mono" > /dev/null
then
echo "mono could not be found. Please read the README.md for installation instructions."
exit
fi

# check for ffmpeg
if ! type "ffmpeg" > /dev/null
then
echo "ffmpeg could not be found. Please read the README.md for installation instructions."
exit
fi

# Some exports to avoid crashes
export MONO_MANAGED_WATCHER=disabled
export MONO_WINFORMS_XIM_STYLE=disabled

# Start TeddyBench
mono TeddyBench.exe
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# Tonie file tool

With this tool you can dump existing files of the famous audio box or create custom ones.

# Linux
WARNING: The `TeddyBench` Linux port has alpha status. So don't use it unless you are a developer and you are able to understand cryptic error messages. It is not fully tested but converting files should work.

It is tested with Ubuntu 20.04.

## Requirements
Please install the following packages

```
# sudo apt install mono-complete xcb ffmpeg libgdiplus libcanberra-gtk-module libcanberra-gtk3-module
```

## Running

### General

You have to run `TeddyBench` with `mono`. Using `wine` is not working.

```
# mono TeddyBench.exe
```

### Know issues
For some reasons TonieBench is running unstable with mono. So you can try the following steps.

**A. Running with sudo (root)**

```
# sudo mono TeddyBench.exe
```

**B. Set some environment variables**

```
# export MONO_MANAGED_WATCHER=disabled
# export MONO_WINFORMS_XIM_STYLE=disabled
# mono TeddyBench.exe
```
## Development
You can compile it directly under Linux with `monodevelop`.
2 changes: 1 addition & 1 deletion Teddy/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
2 changes: 1 addition & 1 deletion Teddy/Teddy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>Teddy</RootNamespace>
<AssemblyName>Teddy</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
Expand Down
27 changes: 22 additions & 5 deletions TeddyBench/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
Expand Down Expand Up @@ -871,7 +872,17 @@ private void btnAdd_Click(object sender, EventArgs e)

if (dlg.ShowDialog() == DialogResult.OK)
{
AddFiles(dlg.FileNames);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// Sort in alphabetical order because the Windows.Form dialog under Linux is scrappy
var list = dlg.FileNames.ToList();
list.Sort();
AddFiles(list.ToArray());
}
else
{
AddFiles(dlg.FileNames);
}
}
}

Expand All @@ -881,13 +892,19 @@ private void AddFiles(string[] fileNames)

if (ask.ShowDialog() == DialogResult.OK)
{
string[] extensions;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
extensions = new String[] {".mp3", ".ogg", ".wav", "wma", "aac"};
else
extensions = new String[] {".mp3"};

if (fileNames.Count() == 1)
{
string fileName = fileNames[0];

if (fileName.ToLower().EndsWith(".mp3"))
if (extensions.Any(ext => fileName.ToLower().EndsWith(ext)))
{
switch (MessageBox.Show("You are about to encode a single MP3, is this right?", "Encode a MP3 file", MessageBoxButtons.YesNo))
switch (MessageBox.Show("You are about to encode an single audio file, is this right?", "Encode an audio file", MessageBoxButtons.YesNo))
{
case DialogResult.No:
return;
Expand Down Expand Up @@ -916,9 +933,9 @@ private void AddFiles(string[] fileNames)
}
else
{
if (fileNames.Where(f => !f.ToLower().EndsWith(".mp3")).Count() > 0)
if (fileNames.Where(f => !extensions.Any(ext => f.ToLower().EndsWith(ext))).Count() > 0)
{
MessageBox.Show("Please select MP3 files only.", "Add file...");
MessageBox.Show("Please select supported audio files only.", "Add file...");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion TeddyBench/TeddyBench.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\ILMerge.3.0.40\build\ILMerge.props" Condition="Exists('..\packages\ILMerge.3.0.40\build\ILMerge.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down
Loading