Mercurial > octave-nkf
view libinterp/dldfcn/__recorder_audiorecorder__.cc @ 19537:36a26a131209
Apply Octave coding style to audio project additions
* libinterp/dldfcn/__player_audioplayer__.cc,
libinterp/dldfcn/__recorder_audiorecorder__.cc,
libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/audioinfo.cc,
libinterp/dldfcn/audioread.cc, libinterp/dldfcn/audiowrite.cc,
libinterp/dldfcn/player_class.cc, libinterp/dldfcn/player_class.h,
libinterp/dldfcn/recorder_class.cc, libinterp/dldfcn/recorder_class.h,
scripts/audio/@audioplayer/__get_properties__.m,
scripts/audio/@audioplayer/audioplayer.m,
scripts/audio/@audioplayer/display.m, scripts/audio/@audioplayer/get.m,
scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/pause.m,
scripts/audio/@audioplayer/play.m,
scripts/audio/@audioplayer/playblocking.m,
scripts/audio/@audioplayer/resume.m, scripts/audio/@audioplayer/set.m,
scripts/audio/@audioplayer/stop.m, scripts/audio/@audioplayer/subsasgn.m,
scripts/audio/@audioplayer/subsref.m,
scripts/audio/@audiorecorder/__get_properties__.m,
scripts/audio/@audiorecorder/audiorecorder.m,
scripts/audio/@audiorecorder/display.m, scripts/audio/@audiorecorder/get.m,
scripts/audio/@audiorecorder/getaudiodata.m,
scripts/audio/@audiorecorder/getplayer.m,
scripts/audio/@audiorecorder/isrecording.m,
scripts/audio/@audiorecorder/pause.m, scripts/audio/@audiorecorder/play.m,
scripts/audio/@audiorecorder/record.m,
scripts/audio/@audiorecorder/recordblocking.m,
scripts/audio/@audiorecorder/resume.m, scripts/audio/@audiorecorder/set.m,
scripts/audio/@audiorecorder/stop.m,
scripts/audio/@audiorecorder/subsasgn.m,
scripts/audio/@audiorecorder/subsref.m: Apply consistent Octave indentation,
spacing, and quoting styles. Strip trailing whitespace. Remove braces from
one-line if-else blocks. Simplify some variable declarations.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Thu, 03 Oct 2013 07:52:58 -0400 |
parents | 1f551d169db2 |
children | d7b55fc1b37d |
line wrap: on
line source
/* Copyright (C) 2013 Vytautas JanĨauskas This file is part of Octave. Octave is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Octave 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "oct.h" #include "ov-struct.h" #ifdef HAVE_PORTAUDIO #include "player_class.cc" #include "recorder_class.cc" #endif DEFUN_DLD (__recorder_audiorecorder__, args, , "__recorder_audiorecorder__") { #ifdef HAVE_PORTAUDIO int nargin = args.length (); audiorecorder* retval = new audiorecorder (); int offset = 0; if (nargin > 0) { bool is_function = args(0).is_string () || args(0).is_function_handle () || args(0).is_inline_function (); if (is_function) { retval->octave_callback_function = args(0).function_value (); offset = 1; } } switch (nargin - offset) { case 3: retval->set_fs (args(0 + offset).int_value ()); retval->set_nbits (args(1 + offset).int_value ()); retval->set_channels (args(2 + offset).int_value ()); break; case 4: retval->set_fs (args(0 + offset).int_value ()); retval->set_nbits (args(1 + offset).int_value ()); retval->set_channels (args(2 + offset).int_value ()); retval->set_id (args(3 + offset).int_value ()); break; } retval->init (); return octave_value (retval); #else octave_value retval; error ("portaudio not found on your system and thus audio functionality is not present"); return retval; #endif } DEFUN_DLD (__recorder_getaudiodata__, args, , "__recorder_getaudiodata__") { octave_value retval; #ifdef HAVE_PORTAUDIO const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->getaudiodata ()); #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_channels__, args, , "__recorder_get_channels__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->get_channels ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_fs__, args, , "__recorder_get_fs__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->get_fs ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_id__, args, , "__recorder_get_id__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->get_id ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_nbits__, args, , "__recorder_get_nbits__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->get_nbits ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_sample_number__, args, , "__recorder_get_sample_number__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->get_sample_number ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_tag__, args, , "__recorder_get_tag__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->get_tag ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_total_samples__, args, , "__recorder_get_total_samples__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = octave_value (recorder->get_total_samples ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_get_userdata__, args, , "__recorder_get_userdata__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); retval = recorder->get_userdata (); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_isrecording__, args, , "__recorder_isrecording__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); if (recorder->isrecording ()) return octave_value (1); else return octave_value (0); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_pause__, args, , "__recorder_pause__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); recorder->pause (); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_recordblocking__, args, , "__recorder_recordblocking__") { octave_value retval; #ifdef HAVE_PORTAUDIO const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); recorder->recordblocking (args(1).float_value ()); #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_record__, args, , "__recorder_record__") { octave_value retval; #ifdef HAVE_PORTAUDIO const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); if (args.length () == 1) { recorder->record (); } else if (args.length () == 2) { recorder->set_end_sample (args(1).int_value () * recorder->get_fs ()); recorder->record (); } else { error ("audiorecorder: wrong number of arguments passed to record"); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_resume__, args, , "__recorder_resume__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 1) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); recorder->resume (); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_set_fs__, args, , "__recorder_set_fs__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 2) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); recorder->set_fs (args(1).int_value ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_set_tag__, args, , "__recorder_set_tag__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 2) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); recorder->set_tag (args(1).char_matrix_value ()); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_set_userdata__, args, , "__recorder_set_userdata__") { octave_value retval; #ifdef HAVE_PORTAUDIO int nargin = args.length (); if (nargin == 2) { const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); recorder->set_userdata (args(1)); } #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; } DEFUN_DLD (__recorder_stop__, args, , "__recorder_stop__") { octave_value retval; #ifdef HAVE_PORTAUDIO const octave_base_value& rep = args(0).get_rep (); audiorecorder *recorder = &((audiorecorder &)rep); recorder->stop (); #else error ("portaudio not found on your system and thus audio functionality is not present"); #endif return retval; }