Tutorial 0 - Audio programming with gtkIOStream

Moderator: flatmax

Post Reply
flatmax
Posts: 604
Joined: Sat Jul 23, 2016 11:39 pm

Tutorial 0 - Audio programming with gtkIOStream

Post by flatmax » Fri Jul 21, 2017 11:59 pm

This tutorial is the first in a series of audio programming tutorials using gtkIOStream. gktIOStream is a C++ development package which allows simple interfacing to audio subsystems in Linux. The two main systems it uses is jackd and ALSA.

The contents of tutorials is available here. In this tutorial we will install gtkIOStream and test that it is setup correctly.

Firstly, we will install the requirements:

Code: Select all

sudo apt-get install libsox-dev libeigen3-dev libfftw3-dev libasound2-dev libjack-jackd2-dev
If you want sox and GTK GUI development the also install them :

Code: Select all

sudo apt install libsox-dev libeigen3-dev libfftw3-dev libasound2-dev libjack-jackd2-dev sox libgtk2.0-dev
libsox-dev is regarded as the swiss army knife of audio. It allows you to manipulate convert audio formats and do many other things, kind of similar to avconv (ffmpeg) but specifically for audio. It handles all audio in 32 bit samples.
eigen is a set of headers which allow array/vector/matrix math processing. They are setup to take advantage of CPU hardware acceleration and they also do fantastically complex math with very simple commands.
fftw3 is regarded as the fastest fft (fast Fourier Transform) library. It can convert time domain data to the frequency domain.
libasound2 is the Linux official sound system, which is built into the kernel. libasound2 is the library which allows you to interface ALSA in a fantastically low level manner.
libjack-jackd2 is great for low latency audio routing - it even lets you route audio over the web!

We also need the necessary development tools :

Code: Select all

sudo apt-get install git g++ autoconf libtool
Next we will install gtkIOStream. We need to clone its git repository :

Code: Select all

git clone https://github.com/flatmax/gtkiostream.git
Great - now lets compile gtkIOStream. To do that we have to change to its directory, reconfigure autotools, configure the make system and make it, then make install it ! ... don't worry, here is how to do that :

Code: Select all

cd gtkiostream
./tools/autotools.sh 
If you have problems at this point, one or other development tool is not installed. Drop a note below and we will fix that.

Now we are ready to configure the make system using autotools :

Code: Select all

./configure --disable-octave
Here we have called configure and told gtkiostream that we don't want to compile in the octave functionality. Octave is a fantastic numerical processing system which is mostly backwards compatible with Matlab.

Now if configure succeeded, then you are ready to compile :

Code: Select all

make -j2
Here we have told the GNU make system to compile gtkIOStream using 2 (-j2) threads.

At this point, after quite some time (on my Pi, around 30 minutes) gtkIOStream should have compiled.

Finally we install it :
sudo make install

We can test the installation by going to our home directory and running a command :

Code: Select all

cd
WSOLA -h
You should see the following output :

Code: Select all

pi@raspberrypi:~ $ WSOLA -h
Usage: WSOLA -h or --help
Usage: WSOLA fileName.wav rate
	 the fileName can be any readable audio file format.
	 the rate can be any number within a reasonable range where 0 < rate < 5 or some reasonable speed.

 Outputs to the file fileName.wav.rate.wav
Checkout the next kickstarter campaign - the Ultra 2 : https://kck.st/2xwM3DL
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

Franshej
Posts: 9
Joined: Mon Jan 22, 2018 4:13 am

Re: Tutorial 0 - Audio programming with gtkIOStream

Post by Franshej » Tue Jan 23, 2018 12:22 am

Hi!

When i run the ./tools/autotools.sh i've got the error message:

configure.ac 29: installing './missing'
applications/Makefile.am installing './depcomp'
applications/Makefile.am 82: warning: variable 'JackFullDuplex_SOURCES' is defined but no program or
applications/Makefile.am 82: library has 'JackFullDuplex' as canonical name (possible typo)
applications/Makefile.am 84: warning: variable 'JackFullDuplex_LDADD' is defined but no program or
applications/Makefile.am 84: library has 'JackFullDuplex' as canonical name (possible typo)
test/Makefile.am 172: warning: '%'-style pattern rules are a GNU make extension
test/Makefile.am 136: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
test/Makefile.am 299: warning: variable 'DeBoorTest_SOURCES' is defined but no program or
test/Makefile.am 299: library has 'DeBoorTest' as canonical name (possible typo)
test/Makefile.am 224: warning: variable 'DecompositionTest_SOURCES' is defined but no program or
test/Makefile.am 224: library has 'DecompositionTest' as canonical name (possible typo)
test/Makefile.am 155: warning: variable 'JackOverRailTest_SOURCES' is defined but no program or
test/Makefile.am 155: library has 'JackOverRailTest' as canonical name (possible typo)
test/Makefile.am 39: warning: variable 'PlotTest3_SOURCES' is defined but no program or
test/Makefile.am 39: library has 'PlotTest3' as canonical name (possible typo)
test/Makefile.am 302: warning: variable 'DeBoorTest_LDADD' is defined but no program or
test/Makefile.am 302: library has 'DeBoorTest' as canonical name (possible typo)
test/Makefile.am 226: warning: variable 'DecompositionTest_LDADD' is defined but no program or
test/Makefile.am 226: library has 'DecompositionTest' as canonical name (possible typo)
test/Makefile.am 157: warning: variable 'JackOverRailTest_LDADD' is defined but no program or
test/Makefile.am 157: library has 'JackOverRailTest' as canonical name (possible typo)

Peter DU
Posts: 2
Joined: Thu Jan 25, 2018 12:28 pm

Re: Tutorial 0 - Audio programming with gtkIOStream

Post by Peter DU » Thu Jan 25, 2018 12:49 pm

HI Matt,

Thank you for the information. I am now trying to use the octo sound card for sound recording and processing in real time. I saw your tutorial and start trying to follow it. However, I got some error at the first stage.

1. The github repo seems moved to another repo.

2. make -j2:

g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT I2SEndianTest-I2SEndianTest.o -MD -MP -MF .deps/I2SEndianTest-I2SEndianTest.Tpo -c -o I2SEndianTest-I2SEndianTest.o `test -f 'I2SEndianTest.C' || echo './'`I2SEndianTest.C
In file included from ../include/IIO/IIODevice.H:21:0,
from ../include/IIO/IIO.H:21,
from ../include/IIO/IIOMMap.H:20,
from IIOSox.C:23:
../include/DirectoryScanner.H: In static member function ‘static int DirectoryScanner::mkDir(const string&, mode_t)’:
../include/DirectoryScanner.H:187:31: error: ‘system’ was not declared in this scope
int ret=system(cmd.c_str());
^
In file included from ../include/IIO/IIOMMap.H:20:0,
from IIOSox.C:23:
../include/IIO/IIO.H: At global scope:
../include/IIO/IIO.H:23:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
#pragma GCC diagnostic ignored "-Wignored-attributes"
^
In file included from IIOSox.C:27:0:
../include/Sox.H:27:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
#pragma GCC diagnostic ignored "-Wignored-attributes"
^
Makefile:669: recipe for target 'IIOSox-IIOSox.o' failed
make[2]: *** [IIOSox-IIOSox.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/I2SEndianTest-I2SEndianTest.Tpo .deps/I2SEndianTest-I2SEndianTest.Po
make[2]: Leaving directory '/home/pi/gtkiostream/applications'
Makefile:502: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/pi/gtkiostream'
Makefile:408: recipe for target 'all' failed
make: *** [all] Error 2

Could you give me some hints about how to solve it? Thank you.

Best,

Peter

flatmax
Posts: 604
Joined: Sat Jul 23, 2016 11:39 pm

Re: Tutorial 0 - Audio programming with gtkIOStream

Post by flatmax » Thu Mar 29, 2018 8:36 pm

Franshej wrote:
Tue Jan 23, 2018 12:22 am
Hi!

When i run the ./tools/autotools.sh i've got the error message:

configure.ac 29: installing './missing'
applications/Makefile.am installing './depcomp'
applications/Makefile.am 82: warning: variable 'JackFullDuplex_SOURCES' is defined but no program or
applications/Makefile.am 82: library has 'JackFullDuplex' as canonical name (possible typo)
applications/Makefile.am 84: warning: variable 'JackFullDuplex_LDADD' is defined but no program or
applications/Makefile.am 84: library has 'JackFullDuplex' as canonical name (possible typo)
test/Makefile.am 172: warning: '%'-style pattern rules are a GNU make extension
test/Makefile.am 136: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
test/Makefile.am 299: warning: variable 'DeBoorTest_SOURCES' is defined but no program or
test/Makefile.am 299: library has 'DeBoorTest' as canonical name (possible typo)
test/Makefile.am 224: warning: variable 'DecompositionTest_SOURCES' is defined but no program or
test/Makefile.am 224: library has 'DecompositionTest' as canonical name (possible typo)
test/Makefile.am 155: warning: variable 'JackOverRailTest_SOURCES' is defined but no program or
test/Makefile.am 155: library has 'JackOverRailTest' as canonical name (possible typo)
test/Makefile.am 39: warning: variable 'PlotTest3_SOURCES' is defined but no program or
test/Makefile.am 39: library has 'PlotTest3' as canonical name (possible typo)
test/Makefile.am 302: warning: variable 'DeBoorTest_LDADD' is defined but no program or
test/Makefile.am 302: library has 'DeBoorTest' as canonical name (possible typo)
test/Makefile.am 226: warning: variable 'DecompositionTest_LDADD' is defined but no program or
test/Makefile.am 226: library has 'DecompositionTest' as canonical name (possible typo)
test/Makefile.am 157: warning: variable 'JackOverRailTest_LDADD' is defined but no program or
test/Makefile.am 157: library has 'JackOverRailTest' as canonical name (possible typo)
These are warnings - latest version from github has far less warnings !
Looks like it is ok.

Matt
Checkout the next kickstarter campaign - the Ultra 2 : https://kck.st/2xwM3DL
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

Chewie
Posts: 1
Joined: Wed Oct 03, 2018 12:05 am

Re: Tutorial 0 - Audio programming with gtkIOStream

Post by Chewie » Wed Oct 03, 2018 12:15 am

Hi Matt,

I recently got a Stereo Card and successfully set up everything. However, when I started to follow this tutorial, and entered "make -j2" I hit an error:

Code: Select all

~/src/gtkiostream $ make -j2

...Skipping a lot of lines...

In file included from ../include/ALSA/ALSA.H:54:0,
                 from LatencyTester.C:24:
../include/ALSA/Mixer.H: In member function ‘int ALSA::Mixer::getElementIndex(unsigned int)’:
../include/ALSA/Mixer.H:191:28: error: ‘__gnu_cxx::__alloc_traits<std::allocator<ALSA::MixerElement> >::value_type {aka class ALSA::MixerElement}’ has no member named ‘id’
       if (mixerElements[i].id==id)
                            ^~
It seems like the code changed? I looked on GitHub (https://github.com/flatmax/gtkiostream/ ... SA/Mixer.H) and it looks like I have the same code in my local repo. Are there any changes I need to make on my end to make this work?



In case you need the setup output for "./tools/autotools.sh" and "./configure --disable-octave":

Code: Select all

~/src/gtkiostream $ ./tools/autotools.sh 
libtoolize  putting auxiliary files in '.'.
libtoolize  copying file './ltmain.sh'
libtoolize  putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize  copying file 'm4/libtool.m4'
libtoolize  copying file 'm4/ltoptions.m4'
libtoolize  copying file 'm4/ltsugar.m4'
libtoolize  copying file 'm4/ltversion.m4'
libtoolize  copying file 'm4/lt~obsolete.m4'
configure.ac 34: installing './compile'
configure.ac 34: installing './config.guess'
configure.ac 34: installing './config.sub'
configure.ac 29: installing './install-sh'
configure.ac 29: installing './missing'
applications/Makefile.am  installing './depcomp'
test/Makefile.am 172: warning: '%'-style pattern rules are a GNU make extension
test/Makefile.am 136: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')


~/src/gtkiostream $ ./configure --disable-octave
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '1000' is supported by ustar format... yes
checking whether GID '1000' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking build system type... armv7l-unknown-linux-gnueabihf
checking host system type... armv7l-unknown-linux-gnueabihf
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert armv7l-unknown-linux-gnueabihf file names to armv7l-unknown-linux-gnueabihf format... func_convert_file_noop
checking how to convert armv7l-unknown-linux-gnueabihf file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... no
checking for g95... no
checking for xlf95... no
checking for f95... no
checking for fort... no
checking for ifort... no
checking for ifc... no
checking for efc... no
checking for pgfortran... no
checking for pgf95... no
checking for lf95... no
checking for ftn... no
checking for nagfor... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking for emscripten compiler... no
checking for doxygen... no
configure: WARNING: Doxygen not found - continuing without Doxygen support
checking for Icee... no
checking for Ice... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GLIB2... yes
checking for GTK... no
checking for GTK3... no
checking for GTK2... yes
checking for GTK... no
checking for GTK... yes
checking for EIGEN... yes
checking for SOX... yes
checking for ALSA... yes
checking for JACK... yes
checking for FFTW3... yes
checking for OPENCV... no
checking for inline... inline
checking for error_at_line... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating applications/Makefile
config.status: creating api/Makefile
config.status: creating test/Makefile
config.status: creating include/Makefile
config.status: creating src/deBoor/Makefile
config.status: creating gtkIOStream.pc
config.status: creating gtkIOStreamORB.pc
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure: 
configure: 
configure: 
configure: SOX ............................................ Present
configure: GTK2 ............................................ Present
configure: Jack ........................................... Present
configure: Octave ......................................... Not present
Octave tests and applications will not be built.
configure: Alsa   ....................................... Present


jglanglo
Posts: 3
Joined: Tue Oct 30, 2018 8:53 am

Re: Tutorial 0 - Audio programming with gtkIOStream

Post by jglanglo » Tue Oct 30, 2018 8:56 am

I made it through everything up until the
make -j2

I get an error message:

make: *** No targets specified and no makefile found. Stop.

I'm not sure what the problem is.

Thank you for your time.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest