From 9d9c6e4845fa552053644701f46c728d609af010 Mon Sep 17 00:00:00 2001 From: fulup Date: Sun, 2 Apr 2017 12:10:49 +0200 Subject: Documentation --- Common/AudioFormat.h | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 +++-- 2 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 Common/AudioFormat.h diff --git a/Common/AudioFormat.h b/Common/AudioFormat.h new file mode 100644 index 0000000..ac0a2b0 --- /dev/null +++ b/Common/AudioFormat.h @@ -0,0 +1,134 @@ +#ifndef FORMATS_H +#define FORMATS_H 1 + +#include +#include + +/* Definitions for .VOC files */ + +#define VOC_MAGIC_STRING "Creative Voice File\x1A" +#define VOC_ACTUAL_VERSION 0x010A +#define VOC_SAMPLESIZE 8 + +#define VOC_MODE_MONO 0 +#define VOC_MODE_STEREO 1 + +#define VOC_DATALEN(bp) ((u_long)(bp->datalen) | \ + ((u_long)(bp->datalen_m) << 8) | \ + ((u_long)(bp->datalen_h) << 16) ) + +typedef struct voc_header { + u_char magic[20]; /* must be MAGIC_STRING */ + u_short headerlen; /* Headerlength, should be 0x1A */ + u_short version; /* VOC-file version */ + u_short coded_ver; /* 0x1233-version */ +} VocHeader; + +typedef struct voc_blocktype { + u_char type; + u_char datalen; /* low-byte */ + u_char datalen_m; /* medium-byte */ + u_char datalen_h; /* high-byte */ +} VocBlockType; + +typedef struct voc_voice_data { + u_char tc; + u_char pack; +} VocVoiceData; + +typedef struct voc_ext_block { + u_short tc; + u_char pack; + u_char mode; +} VocExtBlock; + +/* Definitions for Microsoft WAVE format */ + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24)) +#define LE_SHORT(v) (v) +#define LE_INT(v) (v) +#define BE_SHORT(v) bswap_16(v) +#define BE_INT(v) bswap_32(v) +#elif __BYTE_ORDER == __BIG_ENDIAN +#define COMPOSE_ID(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24)) +#define LE_SHORT(v) bswap_16(v) +#define LE_INT(v) bswap_32(v) +#define BE_SHORT(v) (v) +#define BE_INT(v) (v) +#else +#error "Wrong endian" +#endif + +/* Note: the following macros evaluate the parameter v twice */ +#define TO_CPU_SHORT(v, be) \ + ((be) ? BE_SHORT(v) : LE_SHORT(v)) +#define TO_CPU_INT(v, be) \ + ((be) ? BE_INT(v) : LE_INT(v)) + +#define WAV_RIFF COMPOSE_ID('R','I','F','F') +#define WAV_RIFX COMPOSE_ID('R','I','F','X') +#define WAV_WAVE COMPOSE_ID('W','A','V','E') +#define WAV_FMT COMPOSE_ID('f','m','t',' ') +#define WAV_DATA COMPOSE_ID('d','a','t','a') + +/* WAVE fmt block constants from Microsoft mmreg.h header */ +#define WAV_FMT_PCM 0x0001 +#define WAV_FMT_IEEE_FLOAT 0x0003 +#define WAV_FMT_DOLBY_AC3_SPDIF 0x0092 +#define WAV_FMT_EXTENSIBLE 0xfffe + +/* Used with WAV_FMT_EXTENSIBLE format */ +#define WAV_GUID_TAG "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71" + +/* it's in chunks like .voc and AMIGA iff, but my source say there + are in only in this combination, so I combined them in one header; + it works on all WAVE-file I have + */ +typedef struct { + u_int magic; /* 'RIFF' */ + u_int length; /* filelen */ + u_int type; /* 'WAVE' */ +} WaveHeader; + +typedef struct { + u_short format; /* see WAV_FMT_* */ + u_short channels; + u_int sample_fq; /* frequence of sample */ + u_int byte_p_sec; + u_short byte_p_spl; /* samplesize; 1 or 2 bytes */ + u_short bit_p_spl; /* 8, 12 or 16 bit */ +} WaveFmtBody; + +typedef struct { + WaveFmtBody format; + u_short ext_size; + u_short bit_p_spl; + u_int channel_mask; + u_short guid_format; /* WAV_FMT_* */ + u_char guid_tag[14]; /* WAV_GUID_TAG */ +} WaveFmtExtensibleBody; + +typedef struct { + u_int type; /* 'data' */ + u_int length; /* samplecount */ +} WaveChunkHeader; + +/* Definitions for Sparc .au header */ + +#define AU_MAGIC COMPOSE_ID('.','s','n','d') + +#define AU_FMT_ULAW 1 +#define AU_FMT_LIN8 2 +#define AU_FMT_LIN16 3 + +typedef struct au_header { + u_int magic; /* '.snd' */ + u_int hdr_size; /* size of header (min 24) */ + u_int data_size; /* size of data */ + u_int encoding; /* see to AU_FMT_XXXX */ + u_int sample_rate; /* sample rate */ + u_int channels; /* number of channels (voices) */ +} AuHeader; + +#endif /* FORMATS */ diff --git a/README.md b/README.md index 44b8ec2..3226a7a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ AFB_daemon dependency on Standard Linux Distributions # handle dependencies > (OpenSuse-42.2, Fedora-25, Ubuntu 16.04.2LTS) gcc > 4.8 systemd-devel (libsystemd-dev>=222) - uuid-devel + libuuid-devel file-devel(OpenSuSe) or libmagic-dev(Ubuntu) libjson-c-devel alsa-devel @@ -19,9 +19,9 @@ AFB_daemon dependency on Standard Linux Distributions libopenssl-devel libgcrypt-devel libgnutls-devel (optional but requested by libmicrohttpd for https) OpenSuse >=42.2 - zypper in gcc5 gdb gcc5-c++ cmake ElectricFence systemd-devel libopenssl-devel uuid-devel alsa-devel libgcrypt-devel libgnutls-devel libjson-c-devel file-devel + zypper in gcc5 gdb gcc5-c++ cmake ElectricFence systemd-devel libopenssl-devel libuuid-devel alsa-devel libgcrypt-devel libgnutls-devel libjson-c-devel file-devel - Ubuntu >= 16.4 + Ubuntu >= 16.4libuuid-devel apt-get install cmake electric-fence libsystemd-dev libssl-dev uuid-dev libasound2-dev libgcrypt20-dev libgnutls-dev libgnutls-dev libjson-c-dev libmagic-dev libmicrohttpd with AGL patches http://iot.bzh/download/public/2016/appfw/libmicrohttpd-0.9.49-agl.tgz @@ -76,10 +76,12 @@ ls # Start the binder # From Development Tree - afb-daemon --verbose --token="" --ldpaths=./build --port=1234 --roothttp=./htdoc + mkdir $DEST/share/wssocks + afb-daemon --verbose --token="" --ldpaths=./build --port=1234 --roothttp=./htdoc --ws-server=unix:$DEST/share/wssocks/alsacore # From $INSTALL_DIR - afb-daemon --verbose --token="" --ldpaths=$INSTALL_DIR/lib/audio --port=1234 --roothttp=$INSTALL_DIR/htdocs/audio-bindings + mkdir $INSTALL_DIR/share/wssocks + afb-daemon --verbose --token="" --ldpaths=$INSTALL_DIR/lib/audio --port=1234 --roothttp=$INSTALL_DIR/htdocs/audio-bindings --ws-server=unix:$INSTALL_DIR/share/wssocks/alsacore ``` # replace hd:XX with your own sound card ID ex: "hw:0", "hw:PCH", ... Start a browser on http://localhost:1234?devid=hw:XX -- cgit 1.2.3-korg