Skip to content

Commit

Permalink
docs and more options
Browse files Browse the repository at this point in the history
  • Loading branch information
clrnd committed Dec 5, 2017
1 parent ff6e6b6 commit 6613ec3
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.0)
project(wave2blofeld)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ggdb3 -g")

Expand Down
96 changes: 94 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,97 @@
wave2blofeld
============

A simple tool to transform wavetables in wav into a
Waldorf's Blofeld SysEx midi file.
A simple tool for transforming wavetables from a WAV file
into Waldorf's Blofeld SysEx midi format.

Wavetables must come in a single channel WAV file with 64
waves next to each other, each with 128 (or 256) samples.
The Blofeld has 38 slots (from 80 to 118) for custom Wavetables,
and each can have a 14 character ASCII name.

## Usage

```
USAGE:
wave2blofeld -n <number> [-d] [--] [--version] [-h] <infile>
<outfile>
Where:
-n <number>, --number <number>
(required) Wavetable to write to.
-d, --double
Use only half of the samples for each wave. Useful for banks created
with 256 samples per wave.
--, --ignore_rest
Ignores the rest of the labeled arguments following this flag.
--version
Displays version information and exits.
-h, --help
Displays usage information and exits.
<infile>
(required) Input WAV file.
<outfile>
(required) Output midi file.
A simple tool for transforming wavetables from a WAV file into Waldorf's
Blofeld SysEx midi format.
```

For example, suppose you have a WAV file `wavetable3.wav` that has
8192 samples:

```
$ soxi wavetable3.wav
Input File : 'wavetable3.wav'
Channels : 1
Sample Rate : 44100
Precision : 16-bit
Duration : 00:00:00.19 = 8192 samples = 13.932 CDDA sectors
File Size : 16.4k
Bit Rate : 707k
Sample Encoding: 16-bit Signed Integer PCM
```

Then, you would generate a SysEx file for transfering this
wavetable into slot 82 with the name "Awful Sound" like this:

```
wave2blofeld wavetable3.wav out.mid -n 3 -s "Awful Sound"
```

Then it's just a matter of playing the midi file into the Blofeld with something
like [SysEx Librarian](https://www.snoize.com/SysExLibrarian/).

### Doubled Wavetables

Some programs like [WaveEdit](https://github.com/AndrewBelt/WaveEdit) create
banks with 256 samples per wave. Using the `-d` flag will
skip odd samples so it fits the Blofeld format. This of course
could introduce audible differences.

## Building

First, get the dependencies running make in `deps/`:

```
cd deps/
make
```

After that's done, build it like a normal CMake project:

```
mkdir build && cd build/
cmake ..
make
```
38 changes: 34 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ using uchar = unsigned char;
struct Options {
std::string infile;
std::string outfile;
std::string name;
bool half;
unsigned int slot;
};

Options parseOptions(int argc, char* argv[]){
TCLAP::CmdLine cmd("WAV to Blofeld SysEx", ' ', "0.1");
TCLAP::CmdLine cmd("A simple tool for transforming wavetables from a WAV file into Waldorf's Blofeld SysEx midi format.", ' ', "0.1");

TCLAP::UnlabeledValueArg<std::string>
infile("infile", "Input WAV file.", true, "", "infile");
Expand All @@ -30,23 +32,51 @@ Options parseOptions(int argc, char* argv[]){
cmd.add(outfile);

TCLAP::SwitchArg
half("d", "double", "Use only half of the samples.", cmd, false);
half("d", "double", "Use only half of the samples for each wave. Useful for banks created with 256 samples per wave.", cmd, false);

TCLAP::ValueArg<unsigned int>
slot("s", "slot", "Wavetable to write to.", true, 0, "slot");
cmd.add(slot);

TCLAP::ValueArg<std::string>
name("n", "name", "Wavetable name.", true, "", "name");
cmd.add(name);

cmd.parse(argc, argv);

return Options {
.infile = infile.getValue(),
.outfile = outfile.getValue(),
.half = half.getValue(),
.slot = slot.getValue(),
.name = name.getValue(),
};
}


bool isValid(std::string& s){
return std::all_of(s.begin(), s.end(),
[](char& c){
return 0x20 <= c and c <= 0x7f;
});
}


int main(int argc, char* argv[]){
Options opts = parseOptions(argc, argv);

AudioFile<double> audioFile;
if (opts.slot > 118 or opts.slot < 80) {
std::cerr << "<slot> must be between 80 and 118." << std::endl;
exit(EXIT_FAILURE);
}

if (opts.name.length() > 14 or !isValid(opts.name)) {
std::cerr << "<name> must be less than 14 ASCII characters long."
<< std::endl;
exit(EXIT_FAILURE);
}

AudioFile<double> audioFile;
if (!audioFile.load(opts.infile)) {
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -97,7 +127,7 @@ int main(int argc, char* argv[]){
mm[2] = 0x13; // Blofeld ID
mm[3] = 0x00; // Device ID
mm[4] = 0x12; // Wavetable Dump
mm[5] = 0x51; // Wavetable Number
mm[5] = 0x50 + opts.slot - 1; // Wavetable Number
mm[6] = wave & 0x7f; // Wave Number
mm[7] = 0x00; // Format

Expand Down

0 comments on commit 6613ec3

Please sign in to comment.