<commit_before>// ------------------------------------------------------------------------
// audioio-typeselect.cpp: A proxy class for overriding default keyword
//                         and filename associations.
// Copyright (C) 2001 <NAME> (<EMAIL>)
//
// This program 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 2 of the License, or
// (at your option) any later version.
// 
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
// ------------------------------------------------------------------------

#include "eca-debug.h"
#include "eca-object-factory.h"
#include "audioio-null.h"
#include "audioio-typeselect.h"

/**
 * Constructor.
 */
AUDIO_IO_TYPESELECT::AUDIO_IO_TYPESELECT (void) { 

  ecadebug->msg(ECA_DEBUG::user_objects, 
		"(audioio-typeselect) constructor "
		+ label() + ".");  

  child_repp = new NULLFILE("uninitialized");
  init_rep = false;
}

/**
 * Destructor.
 */
AUDIO_IO_TYPESELECT::~AUDIO_IO_TYPESELECT (void) { 

  ecadebug->msg(ECA_DEBUG::user_objects, 
		"(audioio-typeselect) destructor "
		+ label() + ".");  

  delete child_repp; // either null or the actual child object
}

void AUDIO_IO_TYPESELECT::open(void) throw(AUDIO_IO::SETUP_ERROR&) { 

  ecadebug->msg(ECA_DEBUG::user_objects, "(audioio-typeselect) open " + label() + ".");  

  if (init_rep != true) {
    AUDIO_IO* tmp = 0;
    if (params_rep.size() > 1) {
      string& type = params_rep[1];
      if (type.size() > 0) {
	//  cerr << "typeselect: " << type << endl;
	tmp = ECA_OBJECT_FACTORY::create_audio_object(type);
      }
    }
    if (tmp != 0) {
      delete child_repp; // the placeholder null object
      child_repp = tmp;

      int numparams = child_repp->number_of_params();
      for(int n = 0; n < numparams; n++) {
	//  	cerr << "typeselect: param" << n + 1;
	//  	cerr << " to " << get_parameter(n + 2) << endl;
	child_repp->set_parameter(n + 1, get_parameter(n + 3));
	numparams = child_repp->number_of_params(); // in case 'n_o_p()' varies
      }
      
      child_repp->open();
      label(child_repp->label());
      
      init_rep = true;
    }
  }
}

string AUDIO_IO_TYPESELECT::parameter_names(void) const { 
  return(string("typeselect,format,") + child_repp->parameter_names()); 
}

void AUDIO_IO_TYPESELECT::set_parameter(int param, string value) { 

  ecadebug->msg(ECA_DEBUG::user_objects, 
		"(audioio-typeselect) set_parameter "
		+ label() + ".");  <commit_msg>Bug fixes for typeselect.<commit_after>// ------------------------------------------------------------------------
// audioio-typeselect.cpp: A proxy class for overriding default keyword
//                         and filename associations.
// Copyright (C) 2001 <NAME> (<EMAIL>)
//
// This program 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 2 of the License, or
// (at your option) any later version.
// 
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
// ------------------------------------------------------------------------

#include "eca-debug.h"
#include "eca-object-factory.h"
#include "audioio-null.h"
#include "audioio-typeselect.h"

/**
 * Constructor.
 */
AUDIO_IO_TYPESELECT::AUDIO_IO_TYPESELECT (void) { 

  ecadebug->msg(ECA_DEBUG::user_objects, 
		"(audioio-typeselect) constructor "
		+ label() + ".");  

  child_repp = new NULLFILE("uninitialized");
  init_rep = false;
}

/**
 * Destructor.
 */
AUDIO_IO_TYPESELECT::~AUDIO_IO_TYPESELECT (void) { 

  ecadebug->msg(ECA_DEBUG::user_objects, 
		"(audioio-typeselect) destructor "
		+ label() + ".");  

  delete child_repp; // either null or the actual child object
}

void AUDIO_IO_TYPESELECT::open(void) throw(AUDIO_IO::SETUP_ERROR&) { 

  ecadebug->msg(ECA_DEBUG::user_objects, "(audioio-typeselect) open " + label() + ".");  

  if (init_rep != true) {
    AUDIO_IO* tmp = 0;
    if (params_rep.size() > 1) {
      string& type = params_rep[1];
      if (type.size() > 0) {
	//  cerr << "typeselect: " << type << endl;
	tmp = ECA_OBJECT_FACTORY::create_audio_object(type);
      }
    }
    if (tmp != 0) {
      delete child_repp; // the placeholder null object
      child_repp = tmp;

      int numparams = child_repp->number_of_params();
      for(int n = 0; n < numparams; n++) {
	//  	cerr << "typeselect: param" << n + 1;
	//  	cerr << " to " << get_parameter(n + 2) << endl;
	child_repp->set_parameter(n + 1, get_parameter(n + 3));
	numparams = child_repp->number_of_params(); // in case 'n_o_p()' varies
      }
      
      child_repp->buffersize(buffersize(), samples_per_second());
      child_repp->io_mode(io_mode());
      child_repp->open();
      label(child_repp->label());
      
      init_rep = true;
    }
  }
}

string AUDIO_IO_TYPESELECT::parameter_names(void) const { 
  return(string("typeselect,format,") + child_repp->parameter_names()); 
}

void AUDIO_IO_TYPESELECT::set_parameter(int param, string value) { 

  ecadebug->msg(ECA_DEBUG::user_objects, 
		"(audioio-typeselect) set_parameter "
		+ label() + ".");  
{'fraction_non_alphanumeric': 0.17939313104368124, 'fraction_numerical': 0.009669889963321108, 'mean_word_length': 2.730721393034826, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3811591', 'n_tokens_mistral': 2000, 'n_tokens_neox': 1927, 'n_words': 510}