# The &kwave; Handbook

Thomas
Eschenbacher

    thomas.eschenbacher@gmx.de

1998-2000
Martin Wilz
&version_year;
Thomas Eschenbacher
&FDLNotice;
2014-06-04
&version;

&kwave; is a simple sound editor for KDE.

KDE
multimedia
sound
audio
Kwave
wav
editor
record
playback
sonagram
FFT
Linux

## Introduction

This is "&kwave;", a simple sound editor for KDE-4. Its features include:

- simple cut, copy and paste functions

- multi-level undo/redo

- labeling of signals

- Recording functionality, including pre-recording

- Playback via ALSA and OSS

- Recording via ALSA and OSS

- MP3 import/export

- Ogg/Vorbis import/export

- FLAC import/export

- some analysis functions such as Sonagram

- internally uses 24 bit fixed precision for sample data

- free selectable sample rates

- support for editing of multi channel files

- playback of multi channel audio files (audio output will be mixed down to mono or stereo)

- extendible through an easy-to-use plugin interface

- import/export of other audio formats through audiofile

If you are interested what has been done and what has still to be done, then look at the files `CHANGES` and `TODO` included in the source package. Help and constructive critics are always welcome.

### &kwave; Resources

So if you want to get in contact with the developers, need some further help on using &kwave;, submit patches, bug reports or other stuf, the following resources might be of interest for you:

- Project Homepage

  For information about new up-to-date releases or some other information about this project, take a look at the &kwave; homepage

- Mailing List

  If you need some help on using &kwave; or want to get involved in the development, join the Kwave developer mailing list by visiting "&url_mailinglist;".

- GIT Repository

  There also is a GIT repository, hosted by SourceForge where you can get the sources of the latest development version. For instructions on how to get access to the repository, read in the chapter about building from GIT, or look at "&url_git_instructions;". There also is a nice web interface you can use to browse through the sources.

### &kwave; Revision History

This project has been started by Martin Wilz in summer 1998 and has been developed and improved by him an some other people. In November 1999 Thomas Eschenbacher has started to fix some little bugs here and there and stepped into the source code of the program deeper and deeper. Up to today he has extended, rewritten or revised nearly every component of the program and spent much time on improving it.

Since &kwave; v0.8.0 the changelog is no longer included in this manual. So if you are interested in a complete list of changes, you can find the full history here: &url_changelog; or browse through the sources on your own through the GIT web interface.

## Installation

### How to obtain &kwave;

&kwave; has an own homepage under &url_homepage;. Here you can find further information about the project, as well as information about current stable and up-to-date development versions.

If you want to get a &kwave; release, you have the choice to visit &url_download; and

- download a binary package of the latest stable version, if there is one for your distribution,

- download a source RPM package of the latest stable version,

- compile on your own, from a .tar.bz2 archive with the source code of the latest stable version,

- compile on your own, from the latest GIT source.

Don't be afraid, compiling Kwave should be quite simple even if you are not a programmer. It just needs some developer packages to be installed.

### Requirements

In order to successfully use &kwave;, you need:

- a computer running Linux (&kwave; might also run under some other operating system, but we have never tested this, please let us know if you get it working under some other platform / operating system)

- working sound playback (not really required for using but what would you do with a sound editor if you can't hear the result of your work?)

- KDE-4.5 or higher (at least the libraries, if you are a gnome fan, you can also run &kwave; if the proper libs are installed).

- Qt-4.7 or higher (normally comes with KDE4)

- ALSA 1.0.14 or higher (for record/playback)

- PulseAudio 4.0 or higher (for record/playback)

- id3lib-3.8.1 or higher (for ID3 tags)

- mad-0.15 or higher (optionally for MP3 import/export)

- flac-1.2.0 or higher (for FLAC import/export)

- libsamplerate-0.1.3 or higher (sample rate conversion)

For a more complete and up-to-date list, please consult the 'README' file that is included in the source distribution. This file also contains some special hints for getting &kwave; running and/or building &kwave; under some distributions.

If you intend to compile &kwave; from the sources, you will need at least:

- cmake-2.4.6 or newer

- A recent C/C++ compiler. GCC-4.x works fine, some older and any newer version (like gcc-4.8 and newer) may work too.

- The glibc2 (libc-6) development environment. On SuSE systems the package is called "libc", on other systems it might be called "libc-devel".

- The KDE4 development environment: "kdelibs4-devel", "kdemultimedia4-devel", "kdesdk4".

- The Qt4 development environment, the package is normally called "qt4-devel" or similar.

- pulseaudio-4.0 or newer

- id3lib-devel-3.8.1 or newer

- fftw-3.0 or newer

- mad-devel-0.15 or newer (if you have the permission to use MP3 code)

- flac-devel-1.2.0 newer

- If you intend to get the &kwave; sources via GIT, you will also need a current git package.

- ...many other packages, please take a look at the 'README' file included in the source package.

### Manual Compilation and installation

Since version 0.7.10 &kwave; uses cmake, a make system that is also used by KDE itself. So if you know how to build other KDE applications, you should not have any difficulties in building &kwave;. If you run into problems please report them to the &kwave; mailing list.

In order to compile and install &kwave; on your system, it is best practice to do a out-of-tree build. This means that you hold the sources of &kwave; in one directory and build the package in another (temporary) directory.

For example, assuming that your sources are already unpacked in `$HOME/src/kwave-&version;`, you can do the following:

    % mkdir /tmp/kwave-build
    % cd /tmp/kwave-build
    % cmake $HOME/src/kwave-&version; [build options]
    % make
    % su root -c "make install"

(Specifying build options is a way to enable or disable specific features. See the following section for descriptions)

### Build options

By specifying build options, you can enable or disable some features of &kwave;, like excluding some components or plugins from the generated package. Here is a list of the available options:

- `WITH_ALSA` enable playback/recording via ALSA [`on`/`off`, default=`on`]

- `WITH_DEBUG` build a debug version [`on`/`off`, default=`off`]

- `WITH_DOC` build online documentation [`on`/`off`, default=`on`]

- `WITH_FLAC` enable support for FLAC files [`on`/`off`, default=`on`]

- `WITH_MP3` enable support for mp3 files [`on`/`off`, default=`off`] Please note that you need the permission to use code covered by the MP3 software patents!

- `WITH_OGG_OPUS` enable support for Ogg/Opus files [`on`/`off`, default=`on`]

- `WITH_OGG_VORBIS` enable support for Ogg/Vorbis files [`on`/`off`, default=`on`]

- `WITH_OPTIMIZED_MEMCPY` use an optimized version of memcpy, available for X86, X86_64 and PPC platforms [`on`/`off`, default=`on`]

- `WITH_OSS` enable playback/recording via OSS [`on`/`off`, default=`on`]

- `WITH_PHONON` enable playback via Phonon (for testing only) [`on`/`off`, default=`off`]

- `WITH_PULSEAUDIO` enable playback/recording via PulseAudio [`on`/`off`, default=`on`]

These options can be passed to ``cmake`` with ``-D`option`=`value`. For example, if you want to enable MP3 support, you can pass the corresponding option as follows:

    % cmake [source directory] -DWITH_MP3=ON [other options...]

### Building RPM packages from tar.bz2 archives

#### With working rpmbuild -ta

If you are runnig a system with RPM support, the preferred way to install &kwave; on your system will be the creation of a nice RPM package. First you should get the current source of &kwave;, either as a tar.bz2 archive from the &kwave; download page or check out an up-to-date copy via GIT (like described in the chapter about GIT) and read the next chapter.

If you have downloaded a tar.bz2 archives of &kwave;, create and install the RPMs just by doing the following steps (where [arch] stands for the platform you have built the package and might be something like `i586`, `i686`, `sparc` or whatever, XXX stands for the version number you have downloaded).

To build the &kwave; package and install it do:

    % rpmbuild -ta kwave-XXX.tar.bz2
    % rpm -i /usr/src/redhat/RPMS/[arch]/kwave-XXX.[arch].rpm

Note for SuSE users: you have to specify the directory `/usr/src/packages` instead of `/usr/src/redhat` !

If you haven't seen any errors, then that's it and you can skip the rest of this chapter. If rpm was unable to build the packages and says something like "spec file not found", then go on and read the rest of this section.

#### With broken rpmbuild -ta support

If you can't get `rpmbuild -ta` working, here are the steps for making that manually (the hard way):

1. Go to your RPM "topdir". This normally is `/usr/src/redhat` for the redhat distribution or `/usr/src/packages` if you have the SuSE distribution.

       % cd /usr/src/redhat

2. Put the tar.bz2 archive into the SOURCES subdirectory (you have to replace "somewhere" with the real directory where the files are, of course).

       % cp /somewhere/kwave-XXX.tar.bz2 SOURCES

3. Extract the spec file from the archives and put it into the SPEC subdirectory.

       % tar -xOjf SOURCES/kwave-XXX.tar.bz2 \*.spec > SPECS/kwave.spec

4. Let rpm do the compile job and generate the rpm of &kwave;. If you only want to make a binary package, you can specify `-bb` instead of `-ba`, or just `-bs` to build only a source package.

       % rpmbuild -ba SPECS/kwave.spec

5. If everything was ok, you can install the binary rpm of &kwave;, it will be in the BUILD directory. If you already have a version of &kwave; installed, please remove it first or use the parameter `-U` instead of `-i` for upgrading instead of installing.

       % rpm -ivh BUILD/[arch]/kwave-XXX.[arch].rpm

### Building RPM packages from GIT

#### Checking out the sources

For initially checking out the sources you will need some disk space (about 25 megabytes) in a directory of your choice, the git package of your favorite distribution and full access to the internet. If you get error messages about rejected connections you either have typed something wrong or your provider doesn't give you full access. A good place for the source files will be `"$HOME/src"`.

1. First create the directory that will receive the subdirectoy with &kwave; sources and change into it:

       % mkdir -p $HOME/src
       % cd $HOME/src

2. Then check out the latest sources from the GIT server:

       % git clone &url_git_master; kwave

   or you can check out a specific release with the following commands:

           % git clone &url_git_master; kwave
           % cd kwave
           % git checkout tags/[release-tag]

   You can look up the names of the release tags in the git web page at &url_git_list_tags;. The release tags are always built out of the word `Release-` and the version number of the release, with underscores instead of dots. For example "`Release-&version_tag;`" for v&version;.

There must not be a directory named `kwave` under the directory you want to check out. Otherwise the git program will complain about already existing files and the checkout will not work.

#### Updating fresh sources from GIT

The procedure described in the previous section is only necessary once. For further updates it is much easier. Just change into the directory where you have the checked out sources and do the following to update to the latest version:

    % git pull

Then go on to the next section and compile as usual.

If you think that you have messed up your local source tree or if there are conflicts during updating and you want to start through from a clean state, you can do the following to discard all local changes and switch back to the latest version from the master branch:

    % git clean --force -d
    % git reset --hard
    % git checkout master

#### Compiling

Building rpm package from a GIT snapshot is quite simple. The procedure is nearly the same as described in the last section, so it unhappily also has the same problem with the `rpmbuild -ta` command our method internally uses. Like in the previous chapter, [arch] stands for the platform you have Built the package and might be something like `i386`, `i586`, `sparc` or whatever, XXX stands for the version number you have checked out.

Note for SuSE users: here you have to specify the directory `/usr/src/packages` instead of `/usr/src/redhat` too!

Assuming that you are in the root of where you checked out from GIT, do the following to create a Makefile, the &kwave; package and install it. If you already have a version of &kwave; installed, please remove it first or use `rpm -U` instead of `rpm -i` for updating instead of installing.

    % mkdir /tmp/kwave-build
    % cd /tmp/kwave-build
    % cmake $HOME/src/kwave
    % make rpm
    % rpm -ivh /usr/src/redhat/BUILD/[arch]/kwave-XXX.[arch].rpm

If you still have problems with `make rpm`, you will find the tar.bz2 archive that was produced in `/tmp`. Please follow the instructions in the previous chapter.

### Building a DEB package for testing and personal use

If you want to create a deb package of &kwave;, e.g. for testing a version that is not yet available via official package repositories, then you can create your own package quite easily. First of all, you need to install some required tools:

    % sudo apt-get install build-essential checkinstall

Then you can install the required build dependencies by pretending to install the dependencies of the official &kwave; version:

    % sudo apt-get build-dep kwave

After installing the required packages, you can build &kwave; as described in the chapters before. After building you can type this to get a .deb file in your current build directory:

    % make deb

The .deb file you get from this step will not have the quality that a package from your official distribution has - it is just good enough for installing and safely uninstalling &kwave; for testing purposes and for personal use.

### Building CPU optimized packages

If you are owner of a Pentium, an AMD K6, Athlon or Athlon-XP CPU, you might want to use compiler optimizations to compile your version of &kwave; that is running some percents faster. The gain in speed will be up to 30% on some systems, whereas the functions dealing with signal manipulation and all functions that do complex time-frequency operations (like FFT and Sonagram) will profit most from it.

You do not need to understand much about programming for using an optimized compiler to compile &kwave;, but maybe you will need some time to get the compiler itself working and installed.

#### RPM optimizations

You can easily compile the RPM package optimized for Athlon, Athlon-XP, Pentium and Pentium Pro (and some other CPUs) by using some defines in your `rpmrc` file. You can either modify your system's `rpmrc` file in `/usr/lib/rpm` or the `.rpmrc` file in your home directory. There you can specify option lines like these:

    optflags: i586 -O2 -march=pentium -DNDEBUG -fomit-frame-pointer
    optflags: i686 -O2 -march=pentiumpro -DNDEBUG -fomit-frame-pointer
    optflags: athlon -O2 -march=athlon -DNDEBUG -fomit-frame-pointer
    optflags: k6 -O3 -march=k6 -DNDEBUG -fomit-frame-pointer
    optflags: k7 -O3 -march=athlon-xp -DNDEBUG -fomit-frame-pointer

(I found those nice tricks at http://www.keywarrior.net/duesti/rpmopt.en.html. Thanks to Matthias Düsterhöft!).

This means that on an `k7` architecture the rpm package will be compiled using `-O3 -march=athlon-xp -DNDEBUG -fomit-frame-pointer` as compiler option and so on, you might extend or adapt these to your own needs. The settings apply to all of the sections before in all places where `rpmbuild -ta` is used or where a binary RPM is to be created out of a source rpm using `rpmbuild --rebuild`.

If `rpm` refuses to install your package because it seems not to fit to your computer's architecture, you can normally just install an optimized package by specifying the additional parameter `--ignorearch` and don't care.

#### How to pass optimizer options to the compiler manually

The invocation of the compiler is quite simple. It normally is sufficient to set the environment variables `CFLAGS` and `CXXFLAGS` in the correct way and then compile as usual. For the best settings please consult the documentation or homepage of the corresponding compiler.

If you build &kwave; from a source tree (unpacked tar.bz2 or from GIT) the flags need to be specified before the call. For example:

    % CFLAGS="-O4 -march=athlon-xp -mcpu=athlon-xp -pipe" \
      CXXFLAGS="-O4 -march=athlon-xp -mcpu=athlon-xp -pipe" \
      cmake [source directory]

If you re-build &kwave; from a source rpm package, please follow the instruction in the previous section.

## Basics about digital audio

This chapter should give a short introduction about the basics of digital audio processing, without going too much into details. Of course this might be a bit incomplete, but if you have questions, you can ask at the &kwave; mailing list or consult some further literature.

### The analogue world

First of all, one must know that the world is analogue - but computers work digitally. So there are several ways to convert analogue audio to digital audio and back again. As the way from digital to analogue normally is the reversion of the way from analogue to digital, we only describe the way from analogue to digital.

Conversion from sound to bits

Conversion from sound to bits

Before continuing, analogue audio has to be transformed into electronic signals in order to find it's way into a computer. One common way to do this is by using a microphone and an amplifier. This combination gets sound (changes of air pressure) at it's input and a voltage at it's output. Higher amplitude of the pressure changes will be represented by higher voltages at the amplifier's output. This output is also called a 'signal'. Instead of a microphone you can of course also imagine other sources of audio. And the "amplifier" can be the one that is integrated into your sound card, where you normally can't see it.

Conversion to electronic signal

Conversion to electronic signal

At this stage, the electrical signal has three limitations that one should keep in mind:

1. The amplitude (volume) is limited to some maximum level. This is a consequence of the electronic (amplifiers) that are only able to handle voltages within some specific range. That's no problem as long as sounds are not too loud. In that case the signal would be clipped, which means that the electrical signal will run against it's margins and the result will be disturbed.

2. The frequency range is also limited. Due to the mechanical constrains of microphones and the limited frequency range of amplifiers, a signal's frequency range is limited. There are no hard borders besides which the sound abruptely disappears, but below some low and above some higher frequency the amplitude of the signal starts to decrease more and more. The existance of a maximum frequency can be easily understood as a limited speed of the electrical signal to rise and fall. By using high quality amplifiers and microphones, the limits can be spread into ranges where the human ear is no longer able to hear their results and thus get out of interest. The human ear normally is not able to hear sound above 20 kHz.

3. The signal contains noise. Noise is the most ugly enemy of everyone who has to handle audio signals in any way. Noise is a typical analogue effect, that makes the audio signal "unsharp" and disturbed, it is always present and cannot be avoided. One can only try to use high quality components that produce as low noise as possible, so that one can't hear it. Normally noise has a certain volume, so that the interesting sound should be much louder in comparism to the noise. This is called the signal to noise ratio (SNR), the higher it is the better the sound's quality will be. Sounds that have lower volume than the noise cannot be heart.

### Digitalization

When we want to store and play audio in a computer, we must convert the analogue sound into digital data first. This process is called digitalization. It converts an electronic signal into a sequence of digital values.

Digitalization of the electronic signal

Digitalization of the electronic signal

The conversion can be understood as a repetitive measurement of the electonic signal's value at certain time, thus taking a sample of the signal. The result is then encoded as a digital value.

The sampling could be done in arbitrary distances or in constant intervals. The later method is much easier to handle, and thus it is normally used, with a constant rate - the so-called sample rate. Usual sample rates are 8000, 11025, 22050, and 44100 samples per second. In practice sample rates are also given as frequencies, in Hz or kHz.

The sample rate limts the highest frequency a digitized signal can represent. Due to Shannon's theoreme the highest usable frequency is half of the sample rate, so with 44.1 kHz sample rate you cannot sample signals with more than 22 kHz. To avoid a violation of that half-sample rate rule, your soundcard already has built-in filters that filter away frequencies that are higher than half of the used sample rate.

Sampled signal

Sampled signal

### Sample Encoding

The result of the digital sampling process is a sequence of single samples. One sample is a digital representation of a signal's value at a certain time.

The value of a sample can be interpreted and encoded in several ways. The simplest one is linear encoding. This means that each sample's value directly represents the analogue signal's value multiplied with a constant factor. This is easy to handle, but has the disadvantage that noise will be audibles especially on low amplitudes, where it disturbes most, and less audible on high amplitudes, where it is less audible.

One way to reduce the influence of noise is non-linear encoding. This means that lower amplitudes are amplified before processing. As lower amplitudes are amplified, their distance from noise increases and the quality improves. The most common methods for this are A-Law and U-Law encoding - some standardized logarithmic amplification curves, used in digital telephony (ITU G.711 standard).

Nonlinear Encoding

Nonlinear Encoding

### Sample Formats

Samples can be stored in different formats and precisions. The most common ones are integer (fixed-point) formats, that store values with fixed quantisations. Depending on where the zero line is defined, it has to be destinguished between unsigned (only positive values, "zero line" is at half of the numeric range) and signed (positive and negative values) integer formats.

Signed Format

Signed Format

Unsigned Format

Unsigned Format

As the quantisation loses some accuracy, it produces noise, the so-called quantisation noise. That kind of noise has more effect on low amplitudes, so this method of storing samples is not optimal, but quite easy and very fast to handle (computers are fast in calculating with fixed point numbers).

The second way of encoding samples is with floating point numbers. With floating point numbers, noise is spread nearly equal over all ranges of amplitudes and has advantages especially on low ampliudes. However, this format is much slower when used for processing (computers are much slower on calculating with floating point values in comparison to fixed point numbers).

&kwave; internally uses signed integer format with 24 bit precision, stored in 32 bit integers. This has the disadvantage of higher memory consumption when processing files with lower precision (e.g. 8 bits), but processing 32 bit numbers is very fast and also leaves some reserves for internal calculations, as only 24 bits are normally used.

## Using &kwave;

Here is a little screenshot of the &kwave; main window, so that you get an impression what &kwave; looks like...

Here's a screenshot of &kwave; Screenshot of the Main Window

### Memory Setup

When using &kwave; for the first time, you should go to the memory setup dialog an modify the settings to be suitable for yor needs and the installed memory of your computer. You can reach it under Options Memory... .

Here's a screenshot of &kwave;'s memory setup dialog Screenshot of the Memory Setup Dialog

&kwave; is able to use two types of memory: physical and virtual memory.

Physical memory is the memory (RAM) that is installed in your computer. You should limit the usage of physical memory to some reasonable size, as a rule of thumb, half of the installed memory should be ok. If you set the limit too high, Linux will take memory from other applications, which means that it swaps out memory of other programs to the harddisk (swap), which is rather slow. If you set the limit too low, you might lose some performance when working with big files, because you use less of the fast physical memory than you could.

If you enable virtual memory, &kwave; is able to load and process files that are bigger than the amount of real installed physical memory. &kwave; does this by using temporary files in a configurable directory, which is much faster and more cooperative to other applications than using the operating system's swapping. The directory that you configure should be on your local hard disk.

### Command Line

If you start &kwave; from the command line, you can specify a list of files that should be opened. The first specified file will be opened first, then the other files. Each file will be opened in an own new window of the same &kwave; instance. If you specify wildcards, you can open a large number of files at once.

For example, the following command starts a &kwave; and opens all sounds of the KDE window manager, each in a new window:

    % kwave /usr/share/sounds/KDE_Window*.wav

In addition to a list of files, you can specify a list of Xt toolkit options like `-geometry` for specifying the size and/or position of the first opened &kwave; window and or `-display` for starting the &kwave; on a different display.

For example, the following command starts a &kwave; window with an initial width of 600 pixels and a height of 400 pixels, with the right border positioned 30 pixels away from the right and 0 pixels away form the top of the screen.

    % kwave -geometry 600x400-30+0

With the option `--disable-splashscreen` you can disable the splash screen that comes up when starting &kwave;. This might be useful when you start &kwave; from a script.

The command line option `--iconic` lets &kwave; start up minimized (iconified). This might be useful when you want to start &kwave; without GUI interaction, e.g. when running from a script. This option also implicitly disables the splash screen!

By using the command line option `--logfile=kwave.log` you can log the sequence of actions of a &kwave; session into a file. This is useful for debugging, you might be asked for such a logfile when reporting an error.

### Opening and Saving files

Opening files with &kwave; works like in most other applications, you can

- specify a list of files on the command line when starting &kwave;,

- open an empty &kwave; window (for example with CtrlW File New... ) and put a file into it via drag and drop, or you can

- open a file through the menu with CtrlO File Open

- or one of the last recently opened files under File Open Recent

- save the current file with CtrlS File Save ,

- save under a different name with ShiftCtrlS File SaveAs...

- save all areas that are separated by markers, each one to an own file, with File SaveBlocks...

- or only the current selection with File SaveSelection...

#### Supported File formats

&kwave; supports the following file formats:

- The favourite file format of &kwave; is (like you can guess from the name) `.wav`. This format is very common to other "operating systems" and also is commonly used within the KDE environment.

- The second format that &kwave; supports is "ASCII". You can export to and also import from ASCII. Please be aware that storing in this format might produce very large files! The file format will be described below.

- `.mp3` and `.mp2` import is available through libmad for the MP3 decoding in combination with id3lib for decoding ID3 tags and lame for encoding.

- Ogg/Vorbis (`*.ogg`) import and export. See &url_ogg_vorbis; for details.

- FLAC (`*.flac`) import and export. See &url_flac; for details.

- Additionally &kwave; supports many other common formats through the audiofile plugin. You can import files like `*.au` and `*.snd` (NeXT,Sun Audio), `*.aiff` (Audio Interchange Format) and `*.sf` (Berkeley,IRCAM,Carl Sound Format).

#### Converting to and from .wav

The best way to work with formats other than those supported by &kwave; is to use an external converter program. A good set of tools for this is in the SoX package, they have also some nice documentation!

The plans for future include support for import and also export filters for more formats and maybe some filter that uses a user-defineable script with a call to an external filter, so that even formats not supported by `SoX` (like MP3) can be read and/or written.

#### Format of ASCII files

The ASCII format is quite useful for scientific and educational purposes. Due to it's simple format, you can either write simple files on your own with a text editor or you can use the output of some other application and convert it into ASCII. As the format is really simple, you should not have big problems in writing a converter and most scientific applications use to have some kind of their own ASCII format for export.

The format of an ASCII file is quite simple and has the following rules:

1. At the start of the file comes a block of properties, with one property per line.

2. Each property line starts with `##`.

3. After the properties comes a list of samples, with one sample per line. When using multiple channels, the samples are separated by commas.

4. Lines might end with a carriage return and/or a line feed character (so DOS files are supported too). But when saving, files will always be saved with line feed character as the end of the line.

5. Empty lines and characters after a `#` are treated as comments and are ignored.

6. Values have to be given in signed integer format with a 24 bit range, which is the internal storage format of &kwave;.

7. Everything after a `#` (except property lines, see above) will be treated as comment and will be ignored. Empty lines will also be ignored.

Here is an example of a simple ASCII file that represents a sine wave with eleven samples:

##### content of an ASCII file with a single sine wave

    ## 'rate'=44100
    ## 'tracks'=2
    ## 'bits'=16
    ## 'length'=11
    ## 'Date'='2013-11-09'
    ## 'Software'='Kwave-0.8.11 for KDE 4.11.3'
      5930496,   5930496 #            0
            0,   8388352 #            1
     -5930752,   5930496 #            2
     -8388608,         0 #            3
     -5930752,  -5930752 #            4
            0,  -8388608 #            5
      5930496,  -5930752 #            6
      8388352,         0 #            7
      5930496,   5930496 #            8
            0,   8388352 #            9
     -5930752,   5930496 #           10
    # EOF

### Creating a New File

You can create a new and empty file menu under File New... .

Here's a screenshot of &kwave;'s new file dialog Screenshot of the File New Dialog

You can select the sample rate, resolution in bits per sample and the number of tracks. Per default the file format will be ".wav", but it can still be changed at the time when the file is saved.

The length of the new signal can be set by time (hours, minutes, seconds) or by the number of samples. Additionally you can select it relative to the highest possible length, which is limited by the available memory and &kwave;'s internal limit (2 GB).

### Recording

&kwave; is able to record audio data from various sources, with all sample rates, sample formats and other modes that your sound hardware supports. Currently &kwave; records through the old OSS sound interface, and since v0.7.4 also the newer and more powerful ALSA interface that is the preferred choice for linux kernel 2.6.

The recording can be reached from the menu under File Record .

Here is a screenshot of the &kwave; record dialog, showing the first page with the recording controls during a running recording session. Like in most dialogs of &kwave; you can get some help or see tooltips on the controls.

Here's a screenshot of &kwave;'s record dialog Screenshot of the Record Dialog

Here you have the following controls:

- Pre-Record: If the pre-recording feature of &kwave; is enabled and the recording is startet, &kwave; records into an internal buffer which is some seconds long. If you press the Record ( record button ) button again, then the recording really starts, and also keeps the already pre-recorded data. This is useful for example if you want to record your favorite song from radio, but you recognize too late that the song has started. In this case you can still press the record button and get the start of the song from what &kwave; has already pre-recorded before, so that you will no longer miss a start.

- Record Time: If the length of the recording should be limited to some time, you can activate this setting and select a time in hours, minutes, seconds for your recording. If this option is not enabled, the recording runns until you press the Stop ( stop button ) button.

- Start At: If this setting is activated, you can set a date and time when the recording will be started. Please keep in mind that if the configured time is in the past, the recording will start immediately.

- Record Trigger: If enabled, the recording starts only if the volume of the input goes over a certain limit, which can be defined from 0 to 100% of the highest possible input volume. This is useful if you do not want to record leading silence. (Hint: combine this with the prerecording feature mentioned above to catch also some seconds before reaching the trigger, so that you don't miss any silent fade-ins.)

- The New ( new button ) button is active when the recording is not running or is finished, to discard the current file content and start again.

- The Stop ( stop button ) button is active when the recording or pre-recording is running or &kwave; is waiting for the trigger. If pressed, the current progress will be stopped.

- The Pause ( pause button ) button is active when the recording or pre-recording is running. The first time you press it, the rcording will be halted and the button starts blinking. When you press it again the button will stop blinking and recording will continue immediately, without waiting for a trigger.

- The Record ( record button ) button starts the recording and/or prerecording, depending on the features enabled above:

  1. If neither prerecording nor trigger level are used, the recording starts as soon as you press the record button.

  2. If prerecording is not used and a trigger level is set, the first press will let &kwave; wait for the trigger level to be reached. While waiting for a trigger, you can force the recording to start immediately by pressing the record button again, otherwise the recording will start automatically when the trigger level has been reached.

  3. If prerecording is enabled, the first press starts only the prerecording and the second press really starts the recording.

### Playback

Depending on the compilation options &kwave; is able to play sounds trough one of the following playback methods:

- ALSA (Advanced Linux Sound Architecture): Supercedes OSS, supports more features and more hardware. Might collide with KDE or other applications like OSS does, but has a plugin called "dmix" as a way out. Newer versions of ALSA use a dmix like plugin per default, so this should the best choice for you!

- OSS (Open Sound System): The oldest linux implementation, capable of mono and stereo output. Deprecated since linux kernel 2.6, but still wide spread. Might collide with KDE or other sound applications, only one application at a time can use OSS playback !

Before trying to play sounds, you should take a look on the playback configuration dialog:

Here's a screenshot of &kwave;'s playback setup dialog Screenshot of the Playback Setup Dialog

Currently &kwave; supports only 8 and 16 bit playback, with mono or stereo output through the OSS interface, but many also all modes your sound hardware supports through the ALSA interface.

If your sound file uses more or less channels than the playback allows, all channels will be mixed together during playback. For example if you have a file with three channels and you use stereo playback, the left channel will play channel 0 (upper) and half of channel 1 (middle), the right channel will play the half of channel 1 (middle) and channel 2 (lower).

For getting a smooth playback without interruptions, you should also set the buffer size to an appropriate value. If you encounter problems with interrupted playback, you should increase the buffer size here. But the bigger you set the buffer, the bigger is the latency between the audible sound and the display of the playback position in the signal display.

The playback settings dialog also provides a button for playing a simple test sound. You should hear a 440Hz tone that wanders over all speakers, from one to the next.

Once you have configured playback, you can use the playback controls of the &kwave; main window or through the Play menu or with keyboard shortcuts:

- P Play Start : Start playback of the current selection from it's beginning or the whole file from the current cursor position if nothing was selected. Play only once.

- Play Loop : Like before, but repeat in a loop.

- Space Play Pause : Pause the playback at the current position. Only available when the playback is running.

- Space Play Continue : Continue the playback from the position where it has been paused. Only available if the playback is paused.

- Esc Play Stop : Stop the playback, go back to the start of the selection.

### File Properties

&kwave; is able to handle several meta information that is stored within an audio file. It tries to import and export as much of that information as possible. For example, if you import an MP3 file with ID3 tags, you can keep that information when exporting to a Wave file. If &kwave; would lose meta information when saving, it shows a warning.

You can view and modify the meta information under Edit File Properties... . There you can also change things like sample format, resolution and compression.

Here's a screenshot of &kwave;'s file properties dialog Screenshot of the File Properties Dialog

### Zooming and navigating

&kwave; provides several ways to zoom and navigate, using keyboard shortcuts, menu commands, toolbar buttons and by using the mouse. The following sections should give an overview on how to use all of these functions.

#### Zooming in and out

- zoom to whole signal: selects a zoom factor that makes the whole signal visible in the current window.

  - menu entry: View Zoom to whole signal

  - toolbar button: zoom all button

- zoom to 100%: zooms in up to a scale where on sample is represented by on pixel on the screen.

  - menu entry: View Zoom to 100%

  - toolbar button: zoom to 100% button

- zoom in: zooms in to see more details, magnifies by factor 3.

  - menu entry / keyboard shortcut: Ctrl+ View Zoom In

  - toolbar button: zoom in button

- zoom out: zooms in to see less details, shrinks by factor 3.

  - menu entry / keyboard shortcut: Ctrl- View Zoom Out

  - toolbar button: zoom out button

- zoom selection: zooms to a factor where the current selection is completely visible in the current view.

  - menu entry / keyboard shortcut: CtrlSpace View Zoom to Selection

  - toolbar button: zoom to selection button

- select predefined zoom: select a zoom factor from the zoom combo box in the toolbar.

#### Scrolling left and right

- scroll left: scrolls to the start of the signal by 1/3 of the current view.

  menu entry / keyboard shortcut: cursor Left View Scroll left

  toolbar button: scroll left button

- scroll right: scrolls to the end of the signal by 1/3 of the current view.

  menu entry / keyboard shortcut: cursor right View Scroll right

  toolbar button: scroll right button

- previous page: scrolls to the position right before the current view (left).

  menu entry / keyboard shortcut: Page up View Previous Page

  toolbar button: previous page button

- next page: scrolls to the position right after the current view (right).

  menu entry / keyboard shortcut: Page down View Next Page

  toolbar button: next page button

- to begin: scrolls the current view so that it starts at the beginning of the signal.

  menu entry / keyboard shortcut: Pos1 View Begin

- to end: scrolls the current view so that it ends at the end of the signal.

  menu entry / keyboard shortcut: End View End

#### Using the overview

The main screen of &kwave; shows a small overview of the whole signal above the horizontal scroll bar of the main window. This overview also provides some functionality for navigating:

- single click with left mouse button: directly move the current view to the clicked position.

- double click with left mouse button: directly move the current view to the clicked position and additionally zoom in.

- double click with left mouse button, with shift pressed: directly move the current view to the clicked position and additionally zoom out.

#### Vertical zoom

You can zoom the current view vertically by pressing the Alt key and scrolling with the mouse wheel.

### How to select

&kwave; allows you to select a continuous range of samples as well as any combination of channels (if you edit a multi-channel file). By selecting a range of samples (time scope) all following commands will be limited to that range and by de-selecting a channel it's content will not be changed.

#### Selecting channels

Selecting or de-selecting a channel is quite simple. Just click on the lamp symbol on the left side of the signal to toggle it's state:

green lamp a green lamp means "enabled", whereas

red lamp a red lamp means "disabled".

Note: If a channel is de-selected it will also not be audible for playback!

#### Selecting samples

If you select a range of samples in &kwave;, that range will be inclusive. That means that the first and the last selected sample both belong to the selection and will be used for the following actions. So even if you not selected a range but only a single sample, the selection will never be really "empty". So for example if you see no selected range, the "delete" function applies to that single sample.

The easiest way of selecting a range of samples is just to do that with mouse. It works like you are used from other applications: just press the left mouse button at the point you want to let the selection start and release the button where you want it to end.

If you want to adjust or move the selection's start or end, you can move the mouse cursor near to the start or the end of the selection until it changes from the standard arrow cursor into the left-right arrow cursor and then press the left mouse button and adjust.

You can also extend or shrink the selection to a specific point by holding down the shift button while klicking with the left mouse button. Depending on which border is nearer, the left or right border of the selection will be set to a new position.

There are also some functions available via the menu and of course some keyboard shortcuts:

- select the whole signal: CtrlA Edit SelectionAll

- remove any selection and select "nothing": N Edit SelectionNothing

- the currently visible area: V Edit SelectionVisible

- the next block of samples, starting one sample after the end of the current selection and with the same length: Shift+ Edit SelectionNext

  (Hint: use the "+" key from the numeric keypad!)

- the previous block of samples, ending one sample before the start of the current selection and with the same length: Shift- Edit SelectionPrevious

  (Hint: use the "-" key from the numeric keypad!)

- expand the selection to the start of the signal (first sample): ShiftHome Edit Selectionto start

- expand the selection to the end of the signal (last sample): ShiftEnd Edit Selectionto end

- expand the current selection left and right up to the next label (or start/end of the signal if there is none), starting at the current cursor position: E Edit SelectionExpand to labels

- select the area between the next two labels that are right from the current selection or up to the end of the signal: ShiftCtrlN Edit Selectionto next labels

- select the area between the previous two labels that are left from the current selection or up to the start of the signal: ShiftCtrlP Edit Selectionto previous labels

### Clipboard

&kwave; since v0.8.1 uses the clipboard of KDE. This way it is possible to exchange audio data between different &kwave; windows. It might be possible as well to exchange data between &kwave; and other audio applications, depending on their ability to use the KDE clipboard.

When copying data to the clipboard through the `copy` function &kwave; uses the mime type `audio/vnd.wave` as data format, conforming to RFC 2361 which is the same as the well known `wav` format. When pasting from the clipboard into &kwave; all data formats that are available as file import formats are supported, like for example Ogg/Vorbis, FLAC and so on.

### Drag and Drop

&kwave; supports the KDE Drag and Drop protocol. This enables you to open files just by picking them up in a `konqueror` window or the Desktop and let them drop into a window of &kwave;.

Please note that if you drop a file into a &kwave; window that already contains an opened file, the currently opened file will be closed first and then the file you dropped will be opened in it. If you don't want that, you should open a new empty &kwave; window first.

You can also select a range of samples and drag or drop them into a &kwave; window. Per default the drag operation is done in move mode where the selected range is deleted from the original place and inserted at the drop position. By pressing the Ctrl key you can modify this and drag in copy mode instead.

## Developer's Guide to &kwave;

under construction

Sorry, this chapter is still to be written... At the moment the source code is nearly completely documented with tags suitable with the KDE documentation tools. We currently prefer using doxygen. Maybe some day we will spend some time for writing a tool that converts the doxygen output into something we can include into the docbook source (the source this page has been built of).

If you want to write a plugin, contribute something to this project (or maybe write the converter mentioned above), please feel free to contact one of the authors directly and / or subscribe to the &kwave; mailing list. Help is always welcome!

### Creating API documentation

If you are interested in the internal of &kwave; and you have doxygen installed, then you can type:

    % make apidoc

to get a directory `apicod/html`, with documentation of the source and the internal API in your current build directory.

### Starting in a test environment

If you are developing or testing &kwave;, then you do not necessarily need to uninstall/install &kwave; after every build. Instead you can use the application from where it is built by using a wrapper script. This wrapper script can be built with the follwing command:

    % make wrapper

The script will be named `kw`, feel free to modify it to match your system if needed.

For this to work, you must not have &kwave; installed on your system. If so, please uninstall the package before!

### Adding support for a new Language

1. make system:

   Edit the toplevel `CMakeLists.txt` and add a new entry to the list of languages. Look for the variable `KWAVE_LINGUAS` and add a line for the new language. Each entry consists of a pair with a language code and language name, like this: `<code>`:`<name>`. Example:

       	fr:Francais

   The language code is a 2-letter code which is used for directories and filenames, as it is also used in KDE. The language name is used internally for the docbook online documentation and the online help only. For a list of available language codes and names, please refer to the documentation of the international standard ISO 639.2.

2. user interface:

   Go to the source directory of &kwave; (not the build directory), change into the subdirectory `po` and copy the file `kwave.pot` to the corresponding `.po` file of the language you want to add: `"<code>.po"`. After that you can translate the file using your favorite tool, like `Lokalize`. Example:

       % cd $HOME/src/kwave
       % cd po
       % cp kwave.pot fr.po
       % lokalize fr.po

3. online help:

   This is similar to the procedure for the user interface, but requires some extra steps because the master file is in `docbook` format and the `.pot` template is a generated file. Go to the source directory of &kwave; (not the build directory), change into the subdirectory `doc` and create an empty `.po` file:

       % cd $HOME/src/kwave
       % cd doc
       % touch help_fr.po

   Then change to your build directory (e.g. somewhere in `/tmp`), prepare for building and then generate the `.pot` template (you can safely ignore the error messages that come out at this stage). This template has to be copied to the `.po` file in the source directory of the online help. Example:

       % mkdir /tmp/kwave-build
       % cd /tmp/kwave-build
       % cmake $HOME/src/kwave
       % make doc
       % cp doc/help_en.pot $HOME/src/kwave/doc/help_fr.po

   Now you can translate the `.po` file, like above:

       % cd $HOME/src/kwave
       % cd doc
       % lokalize help_fr.po

4. screenshots:

   For the online documentation you also need screenshots that use the translated messages. This requires a built and installed &kwave; package, so you should follow the steps mentioned in the section about Manual Compilation and installation. Of course you must not pass the build option `WITH_DOC=no` or any other build option that removes functionality, otherwise you would not be able to get screenshots of components that you have disabled.

   For a list of screenshots you can look into one of the existing directories in the source tree, for example in `$HOME/doc/de`. All screenshots are in `.png` and should follow the KDE Documentation Screenshots Requirements. Here in short:

   - Window decoration: Oxygen

   - Widget style: Oxygen

   - Colors: Oxygen

   - Background: Flat color - Color must be white

   - Run X11 in 72dpi mode

   - Save the files in 8bpp

   - Try to keep the size of each file below 20kB

5. desktop file:

   Add a Comment line for the new language to the file `kwave/kwave.desktop.in`. Please note that this file is UTF-8 encoded! Example:

       	Comment[fr]=Un éditeur de sons pour KDE

Useful links:

- RFC 3066 Tags for the Identification of Languages

- KDE Localization contains a lot of useful links for KDE translators.

- Lokalize is the standard tool that helps you translating `.po` files.

- KDE Documentation Screenshots Requirements.

## Questions and Answers

What do I need to compile &kwave;?

Read in the chapter mentioned before.

Which sound cards does &kwave; support?

&kwave; does not need support for any special sound card. The sound card only has to be supported by your operating system and &kwave; uses it's interface to the operating system's sound driver through a OSS or ALSA interface. So &kwave; can play on any sound card that KDE is able to play on.

Why does &kwave; consume more memory than it can be expected from the size of the opened file?

The reason for this is that &kwave; internally stores all samples in 32-bit integers. This was easy to program, made the application faster and a bit more reliable. So if you load an 8-bit file with about one megabyte it will consume about four megabytes. Maybe we will change this somewhere in the future...

Which sound formats does &kwave; support?

&kwave; currently supports .wav files with 8, 16 and 24 bits per sample, with any number of channels (of course including mono and stereo). Additionally it can import all file types that libaudiofile supports and some other formats like Ogg/Vorbis and MP3.

What if I have files with a format not supported by &kwave;?

If you have to work on a different format, you can convert it into .wav format. A good set of tools for this is in the SoX package, they have also some nice documentation!

I get errors when I want to do playback?

Maybe you have chosen a combination of playback rate and sample size that is not supported by your sound driver and / or sound hardware. Try playback with 8 bits per sample and mono first, this should always work. Then try to increase the bits per sample and stereo playback step by step. Note that some playback rates are not at all supported by some sound hardware.

The playback seems to do something but I hear nothing?

Maybe you have forgotten to increase the volume of the playback channel. &kwave; is not responsible for changing the playback volume.

Some files are played with half-speed?

Try choosing a different sound playback device.

The playback sometimes is disturbed and interrupted?

You should increase the size of the playback buffer to get a "smoother" playback (this also makes the playback control reacting a bit slower).

The playback does not stop if I immediately press the stop button?

The reason for this is that the sound driver already has received some playback data from &kwave; at the moment when you press the stop button. Decrease the size of the playback buffer and it should react faster (but makes interruptions more probable).

Is ALSA supported?

Yes, since v0.7.4 for playback and recording

What about playback with 18, 20, 24 or 32 bits per sample or more than two channels?

This is possible through the ALSA interface, since v0.7.4.

What about MP3 support?

Well, as long as there are patent issues, we support only MP3 import through the mad library and export via the external program lame. Additionally you need to have the permission to use code covered by the MP3 patents when generating a Kwave package for distributing!

## Credits and License

&kwave;

Program copyright from 1998-2000 Martin Wilz martin@wilz.de

Program copyright since 2000 Thomas Eschenbacher thomas.eschenbacher@gmx.de

For a complete list of authors and licenses of all files, please refer to the `LICENSES` file, which is included in the sources. There also is a file with the name `AUTHORS` that lists all authors and contributors of &kwave;.

Documentation copyright (C) &version_year; Thomas Eschenbacher thomas.eschenbacher@gmx.de

&underFDL; &underGPL;

### Main Authors

- Martin Wilz martin@wilz.de

  creator of the project, active development 1998-2000

- Thomas Eschenbacher thomas.eschenbacher@gmx.de

  maintainer since 2000, core development

### Major Contributors

- Aurelien Jarno aurel32@debian.org

  debian packager, patches

- Carlos R pureacetone@gmail.com

  spanish translation

- David Flogeras dflogera@nbnet.nb.ca

  Notch Filter plugin

- Gilles Caulier caulier.gilles@free.fr

  i18n, french translations, splashscreen, beta tester

- Pavel Fric pavelfric@seznam.cz

  Czech translation

- Ralf Waspe rwaspe@web.de

  Help/About plugin

- Sven-Steffen Arndt ssa29@gmx.de

  homepage, german translation

### Minor contributors, copyright holders and others

- Aaron Holtzman aholtzma@ess.engr.uvic.ca

  libkwave/cpu_accel.cpp

- Bertrand Songis bsongis@gmail.com [historic]

  french translation fixes, substitutes for patented libaudiofile code, debian bug 419124

- Carsten Lohrke carlo@gentoo.org

  svn r2163, patch for libaudiofile detection

- Chris Vaill chrisvaill@gmail

  code base for the normalize plugin

- David Faure faure@kde.org

  cmake/FindAlsa.cmake

- Diederick de Vries diederick76@gmail.com

  packaging for Crux Linux

- Espen Sand espen@kde.org + Mirko Boehm mirko@kde.org

  K3AboutContainer, base of KwaveAboutContainer

- Everaldo Coelho contact@everaldo.com

  the crystal icon theme http://www.everaldo.com/crystal/

- Jaroslav Kysela

  parts of plugins/playback/PlayBack-ALSA.cpp

- Jeff Tranter

  parts of plugins/pitch_shift/PitchShiftFilter.{h,cpp}

- Juhana Sadeharju kouhia@nic.funet.fi

  plugins/band_pass/BandPass.{h,cpp}, plugins/lowpass/LowPassFilter.cpp, plugins/notch_filter/NotchFilter.{h,cpp}

- Kurt Roeck Q@ping.be

  svn r1370, fix for debian bug#288781, compilation for amd64

- Mark Donohoe (KDE) donohoe@kde.org

  some icons and bitmaps for toolbar and GUI

- Martin Hinsch vidas@sourceforge.net

  Matrix class

- Matthias Kretz kretz@kde.org

  cmake/FindAlsa.cmake

- Miguel Freitas

  parts of libkwave/memcpy.c

- Paul Mackerras paulus@samba.org

  libkwave/ppcasm_string.h, libkwave/ppcasm_string.S, libkwave/ppc_asm.tmpl

- Richard Laerkaeng, richard@goteborg.utfors.se

  cmake/FindOggVorbis.cmake

- Rik Hemsley rik@kde.org

  level meter

- Stefan Westerfeld stefan@space.twc.de

  parts of plugins/pitch_shift/PitchShiftFilter.{h,cpp}

- Joerg-Christian Boehme joerg@chaosdorf.de

  plugins/record/Record-PulseAudio.cpp plugins/record/Record-PulseAudio.h

### Thanks To

- Martin Kuball makube@user.sourceforge.net

  beta tester

- Jorge Luis Arzola arzolacub@gmx.de

  packaging for SuSE Linux

- Michael Favreau michel.favreau@free.fr

  packaging for Arch Linux

- Matthias Düsterhöft duesti@gmx.de

  for information about RPM optimization

- T.H.F. Klok and Cedric Tefft

  maintainers of the id3lib library

- Robert Leslie rob@mars.org

  author of the mad mp3 decoder library

- Robert M. Stockmann stock@stokkie.net

  packaging for Mandrake / X86_64

- Erik de Castro Lopo erikd@zip.com.au

  author of the sndfile library

- Michael Pruett mpruett@sgi.com

  author of the audiofile library