<commit_before>/*
 * Copyright (c) 2008 Cooper Street Innovations
 * 		<<EMAIL>>
 *
 * This library 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.
 *
 * 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

/* nomenclature of in/out,...
 *    inchannel    : read-only "input" data (as produced by a microphone or an application, before being passed to us)
 *    outchannel   : write-only "output" data (will be send to soundcard or an application, generated by us)
 *    sourcechannel: channel being passed from soundcard to application
 *    sinkchannel  : channel being passed from application to soundcard (has the same number of in- and outchannels)
 *
 * the LADSPA-plugin must have
 *    (source.inchannels +sink.inchannels ) inputs
 *    (source.outchannels+sink.outchannels) outputs
 *
 *    for simplicity reasons source.inchannels==source.outchannels (same for sink)
 */

#include <stdio.h>
#include <alsa/asoundlib.h>
#include <alsa/pcm.h>
#include <alsa/pcm_external.h>
#include <alsa/control.h>
#include <linux/soundcard.h>

#include <ladspa.h>
#include "ladspa_utils.h"

static void print_pcm_extplug(snd_pcm_extplug_t*ext) {

  printf("EXTPLUG: %p\n", ext);
  printf("EXTPLUG: name=%s\n", ext->name);
  printf("EXTPLUG: version=%d\n", ext->version);
  printf("EXTPLUG: callback=%p\n", ext->callback);
  printf("EXTPLUG: private_data=%p\n", ext->private_data);
  printf("EXTPLUG: pcm=%p\n", ext->pcm);
  printf("EXTPLUG: stream=%d\n", ext->stream);
  printf("EXTPLUG: format=%d\n", ext->format);
  printf("EXTPLUG: subformat=%d\n", ext->subformat);
  printf("EXTPLUG: channels=%d\n", ext->channels);
  printf("EXTPLUG: rate=%d\n", ext->rate);
  printf("EXTPLUG: slave_format=%d\n", ext->slave_format);
  printf("EXTPLUG: slave_subformat=%d\n", ext->slave_subformat);
  printf("EXTPLUG: slave_channels=%d\n", ext->slave_channels);
  printf("\n");
}

static void print_pcm_config(snd_config_t*config, const char*name) {
  int err;
  const char*str;

  printf("SNDCONFIG[%p]: '%s'=[%d]\n", config, name, snd_config_get_type(config));
  err=snd_config_get_id(config, &str);
  printf("SNDCONFIG[%p]: id[%d]=%s\n", config, err, str);
  err=snd_config_get_string(config, &str);
  printf("SNDCONFIG[%p]: string[%d]=%s\n", config, err, str);
  printf("\n");
}

typedef struct _iemladspa_audiobuf {
  unsigned int frames;
  unsigned int channels;
  size_t size;
  float *data;
} iemladspa_audiobuf_t;

typedef struct snd_pcm_iemladspa {
	snd_pcm_extplug_t ext;
	void *library;
	const LADSPA_Descriptor *klass;

  iemladspa_audiobuf_t inbuf ;
  iemladspa_audiobuf_t outbuf;
  int stream_direction;

	LADSPA_Control *control_data;
	LADSPA_Handle *plugininstance;
} snd_pcm_iemladspa_t;

static void audiobuffer_free(iemladspa_audiobuf_t *iemladspa) {
  if(iemladspa->data)free(iemladspa->data);
  iemladspa->data=NULL;
  iemladspa->frames=0;<commit_msg>put typedefs to beginning of file<commit_after>/*
 * Copyright (c) 2008 Cooper Street Innovations
 * 		<<EMAIL>>
 *
 * This library 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.
 *
 * 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

/* nomenclature of in/out,...
 *    inchannel    : read-only "input" data (as produced by a microphone or an application, before being passed to us)
 *    outchannel   : write-only "output" data (will be send to soundcard or an application, generated by us)
 *    sourcechannel: channel being passed from soundcard to application
 *    sinkchannel  : channel being passed from application to soundcard (has the same number of in- and outchannels)
 *
 * the LADSPA-plugin must have
 *    (source.inchannels +sink.inchannels ) inputs
 *    (source.outchannels+sink.outchannels) outputs
 *
 *    for simplicity reasons source.inchannels==source.outchannels (same for sink)
 */

#include <stdio.h>
#include <alsa/asoundlib.h>
#include <alsa/pcm.h>
#include <alsa/pcm_external.h>
#include <alsa/control.h>
#include <linux/soundcard.h>

#include <ladspa.h>
#include "ladspa_utils.h"


typedef struct _iemladspa_audiobuf {
  unsigned int frames;
  unsigned int channels;
  size_t size;
  float *data;
} iemladspa_audiobuf_t;

typedef struct snd_pcm_iemladspa {
	snd_pcm_extplug_t ext;

  snd_config_t   *sndconfig;

	void *library;
	const LADSPA_Descriptor *klass;

  iemladspa_audiobuf_t inbuf ;
  iemladspa_audiobuf_t outbuf;
  int stream_direction;

	LADSPA_Control *control_data;
	LADSPA_Handle *plugininstance;
} snd_pcm_iemladspa_t;

static void print_pcm_extplug(snd_pcm_extplug_t*ext) {

  printf("EXTPLUG: %p\n", ext);
  printf("EXTPLUG: name=%s\n", ext->name);
  printf("EXTPLUG: version=%d\n", ext->version);
  printf("EXTPLUG: callback=%p\n", ext->callback);
  printf("EXTPLUG: private_data=%p\n", ext->private_data);
  printf("EXTPLUG: pcm=%p\n", ext->pcm);
  printf("EXTPLUG: stream=%d\n", ext->stream);
  printf("EXTPLUG: format=%d\n", ext->format);
  printf("EXTPLUG: subformat=%d\n", ext->subformat);
  printf("EXTPLUG: channels=%d\n", ext->channels);
  printf("EXTPLUG: rate=%d\n", ext->rate);
  printf("EXTPLUG: slave_format=%d\n", ext->slave_format);
  printf("EXTPLUG: slave_subformat=%d\n", ext->slave_subformat);
  printf("EXTPLUG: slave_channels=%d\n", ext->slave_channels);
  printf("\n");
}

static void print_pcm_config(snd_config_t*config, const char*name) {
  int err;
  const char*str;

  printf("SNDCONFIG[%p]: '%s'=[%d]\n", config, name, snd_config_get_type(config));
  err=snd_config_get_id(config, &str);
  printf("SNDCONFIG[%p]: id[%d]=%s\n", config, err, str);
  err=snd_config_get_string(config, &str);
  printf("SNDCONFIG[%p]: string[%d]=%s\n", config, err, str);
  printf("\n");
}

static void audiobuffer_free(iemladspa_audiobuf_t *iemladspa) {
  if(iemladspa->data)free(iemladspa->data);
  iemladspa->data=NULL;
  iemladspa->frames=0;
{'fraction_non_alphanumeric': 0.12835906232132646, 'fraction_numerical': 0.006003430531732418, 'mean_word_length': 4.855230125523012, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 55, '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': '604389', 'n_tokens_mistral': 2456, 'n_tokens_neox': 2359, 'n_words': 670}