summaryrefslogtreecommitdiff
path: root/src/airecord.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/airecord.cc')
-rw-r--r--src/airecord.cc146
1 files changed, 0 insertions, 146 deletions
diff --git a/src/airecord.cc b/src/airecord.cc
deleted file mode 100644
index e340832..0000000
--- a/src/airecord.cc
+++ /dev/null
@@ -1,146 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * audioin.h
- *
- * Fri Apr 8 15:37:21 CEST 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of libaudioin.
- *
- * LibAudioIO is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * LibAudioIO is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with LibAudioIO; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "audioin.h"
-
-int main(int argc, char *argv[])
-{
- int err = 0;
-
- if(argc < 4) {
- printf("Usage %s samplerate num_channels output_file\n", argv[0]);
- return 1;
- }
-
- int samplerate = atoi(argv[1]);
- int channels = atoi(argv[2]);
- char *fname = argv[3];
-
- struct ai_t *ai = ai_init(&err, "default", "Capture", samplerate, channels);
- if(ai == NULL || err) printf("Error: %d\n", err);
-
- if(!ai) {
- printf("Trying alternative mixer interface (not running on an InterCom)\n");
- //ai = ai_init(&err, "default", "H/W Multi", samplerate, channels);
- ai = ai_init(&err, "default", "Capture", samplerate, channels);
- if(ai == NULL || err) printf("Error: %d\n", err);
- }
-
- /** Chip: IDT 92HD83C1C5
-Simple mixer control 'Master',0
-Simple mixer control 'Headphone',0
-Simple mixer control 'Speaker',0
-Simple mixer control 'Front',0
-Simple mixer control 'Front Mic Jack Mode',0
-Simple mixer control 'Line',0
-Simple mixer control 'Line Jack Mode',0
-Simple mixer control 'Line',1
-Simple mixer control 'Mic',0
-Simple mixer control 'IEC958',0
-Simple mixer control 'IEC958 Default PCM',0
-Simple mixer control 'Capture',0
-Simple mixer control 'Capture',1
-Simple mixer control 'Input Source',0
-Simple mixer control 'Input Source',1
-Simple mixer control 'Internal Mic',0
- **/
-
- /** Chip: Realtek ALC662 rev1
-Simple mixer control 'Master',0
-Simple mixer control 'Headphone',0
-Simple mixer control 'Front',0
-Simple mixer control 'Front Mic',0
-Simple mixer control 'Front Mic Boost',0
-Simple mixer control 'Surround',0
-Simple mixer control 'Center',0
-Simple mixer control 'LFE',0
-Simple mixer control 'Line',0
-Simple mixer control 'IEC958',0
-Simple mixer control 'IEC958 Default PCM',0
-Simple mixer control 'Capture',0
-Simple mixer control 'Capture',1
-Simple mixer control 'Auto-Mute Mode',0
-Simple mixer control 'Input Source',0
-Simple mixer control 'Input Source',1
-Simple mixer control 'Rear Mic',0
-Simple mixer control 'Rear Mic Boost',0
- **/
- // 'Capture' record enabled, Input Source: 'Line'
-
-
-
-
- ai_set_mixer_level(&err, ai, 0, 1.0);
- ai_set_mixer_level(&err, ai, 1, 1.0);
-
- short pcm[4096 * 10];
- FILE *fp = fopen(fname, "w");
- if(!fp) {
- printf("Could not write %s\n", fname);
- return 1;
- }
-
- for(size_t i = 0; i < 500; i++) {
- memset(pcm, 0, sizeof(pcm));
- int r = ai_read(&err, ai, pcm, sizeof(pcm));
- if(r < 0 || err) printf("Error: %d\n", err);
-
- // for(int j = 0; j < 20; j++) pcm[j] = 0;
-
- int bufsz = r / (sizeof(short) * channels) ;
- int offset = 160 / (1024 / bufsz);
- int len = 16;
- short start[] = {
- pcm[ (bufsz - offset - 2) * 2],
- pcm[ (bufsz - offset - 2) * 2 + 1]
- };
- short stop[] = {
- pcm[ (bufsz - offset + len + 1) * 2],
- pcm[ (bufsz - offset + len + 1) * 2 + 1]
- };
- for(int j = 0; j < len; j++) {
- float d = (float)j / (float)len;
- pcm[(bufsz - offset + j - 1) * 2] = start[0] * (1 - d) + stop[0] * d;
- pcm[(bufsz - offset + j - 1) * 2 + 1] = start[1] * (1 - d) + stop[1] * d;
- }
- /*
- short m = 32000;
- pcm[(bufsz - offset) * 2] = m;
- pcm[(bufsz - offset) * 2 + 1] = m;
- pcm[(bufsz - offset + len) * 2] = m;
- pcm[(bufsz - offset + len) * 2 + 1] = m;
- */
- if(fwrite(pcm, r, 1, fp)) {}
- }
- fclose(fp);
- ai_close(&err, ai);
-
- return 0;
-}