Skip to content

Commit

Permalink
Merge pull request #797 from bjklemme-intel/alsa_timed_audio
Browse files Browse the repository at this point in the history
adds timed audio
  • Loading branch information
andrew-elder authored Jun 20, 2018
2 parents 5b95644 + 736ed60 commit 6788f2f
Show file tree
Hide file tree
Showing 30 changed files with 7,099 additions and 0 deletions.
94 changes: 94 additions & 0 deletions examples/alsa_timed_audio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
ALSA_INC=/usr/include/alsa
ISAUDK_ROOT:=$(strip $(shell dirname $(realpath $(lastword \
$(MAKEFILE_LIST)))))
ISAUDK_INC=$(ISAUDK_ROOT)
DOC_DIR=$(ISAUDK_ROOT)/documentation

PTP_INC=$(ISAUDK_ROOT)/../../daemons/gptp/common

CFLAGS=-g -I$(ISAUDK_INC) -Wall -Wextra -Wno-unused-but-set-variable -Werror
EXTERNAL_LIBS=-lasound -lpthread -lsndfile
EXTERNAL_LIB_DIRS=-L/usr/local/lib/

QUIET_CC=@/bin/echo -e '* [CC]\t\t$@';
QUIET_MD=@/bin/echo -e '* [MAKEDEP]\t$@';
QUIET_LD=@/bin/echo -e '* [LD]??$@ {$^}' | fold -w 62 -s | \
sed -e '1h;2,$$H;$$!d;g' -re 's/\n/\n\t\t/g;s/\?/\t/g';

TEST_TARGETS=alsa_test
PYTHON_HELPERS=play_file_at record_file_at monoraw_to_net_time \
net_time_to_monoraw

.PHONY: all
all: $(TEST_TARGETS) $(PYTHON_HELPERS)

.PHONY: clean
clean:
/usr/bin/env rm -f *.o $(TEST_TARGETS) $(PYTHON_HELPERS)

.PHONY: pristine
pristine: clean
/usr/bin/env rm -f *~ *.d \#*

%.o: %.c
$(QUIET_CC) $(CC) $(CFLAGS) -c $< -o $@

%.d: %.c
$(QUIET_MD) $(CC) $(CFLAGS) -MM $< -o $@

-include alsa.d
alsa.o: CFLAGS += -I$(ALSA_INC)

-include monoraw_to_net_time.d
monoraw_to_net_time.o: CFLAGS += -I$(PTP_INC)

-include net_time_to_monoraw.d
net_time_to_monoraw.o: CFLAGS += -I$(PTP_INC)

-include linked_list.d

-include stack.d

-include stream.d

-include mixer.d

-include thread_signal.d

-include args.d

-include alsa_test.d

-include capture.d

alsa_test: alsa_test.o alsa.o stream.o mixer.o linked_list.o thread_signal.o \
stack.o capture.o
$(QUIET_LD) $(CC) $(CFLAGS) $^ -o $@ $(EXTERNAL_LIB_DIRS) \
$(EXTERNAL_LIBS)

-include play_file_at.d

play_file_at: play_file_at.o args.o stream.o mixer.o linked_list.o alsa.o \
thread_signal.o stack.o capture.o
$(QUIET_LD) $(CC) $(CFLAGS) $^ -o $@ $(EXTERNAL_LIB_DIRS) \
$(EXTERNAL_LIBS)

-include record_file_at.d

record_file_at: record_file_at.o args.o stream.o capture.o alsa.o \
thread_signal.o linked_list.o mixer.o stack.o
$(QUIET_LD) $(CC) $(CFLAGS) $^ -o $@ $(EXTERNAL_LIB_DIRS) \
$(EXTERNAL_LIBS)

monoraw_to_net_time: monoraw_to_net_time.o args.o
$(QUIET_LD) $(CC) $(CFLAGS) $^ -o $@ -lrt

net_time_to_monoraw: net_time_to_monoraw.o args.o
$(QUIET_LD) $(CC) $(CFLAGS) $^ -o $@ -lrt

.PHONY: docs
docs:
cd $(DOC_DIR); PROJECT_ROOT=$(ISAUDK_ROOT) SRC_DIR=$(ISAUDK_ROOT) \
doxygen Doxyfile
cd $(DOC_DIR)/latex; $(MAKE) pdf
cp $(DOC_DIR)/latex/refman.pdf $(ISAUDK_ROOT)/documentation.pdf
65 changes: 65 additions & 0 deletions examples/alsa_timed_audio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<h1>
Introduction
</h1>
The Intel Synchronized Audio Toolkit consists of several pieces of sample
code that wrap ALSA timing primitives. It contains building blocks for a time
aware mixer and capture module. It uses the OpenAVB time sync daemon for
the 802.1AS protocol.

There are several Python scripts that use this example code creating a simple
demo that measures distance between two devices

<h1>
Prerequisites
</h1>
- **libsndfile** development package/source
- **Doxygen**
- **pdxlatex** - usually part of **TeX Live** package

<h1>
Building
</h1>
<h2>
Build sample applications
</h2>
Checkout the Open-AVB submodule:
<pre>
git submodule update --init
</pre>
In the support directory run:
<pre>
make
</pre>
This generates the time sync daemon and helper application for the ranging
demo that finds a "chirp" signal given an audio file

In the top level directory run:
<pre>
make
</pre>
<h2>
Build the documentation
</h2>
In the top level directory run:
<pre>
make docs
</pre>
Produces <i>documentation.pdf</i> in the top level directory.
<h1>
Running the demo
</h1>
In the support/RangingDemo directory run:
<pre>
./RangingDemo <-p|-r> -d \<peer IP address\> -i \<local interface name\>
</pre>

One machine should use the -p flag to play audio, the other machine should
use the -r flag, to record audio.

<h1>
Example applications
</h1>
<p>@subpage play_at</p>
<p>@subpage record_at</p>
<p>@subpage sys_to_net_time</p>
<p>@subpage net_to_sys_time</p>
Loading

0 comments on commit 6788f2f

Please sign in to comment.