<commit_before>/*
 * libremix -- An audio mixing and sequencing library.
 *
 * Copyright (C) 2001 Commonwealth Scientific and Industrial Research
 * Organisation (CSIRO), Australia.
 *
 * 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 of the License, or (at your option) any later version.
 *
 * This library 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
 *
 */

/*
 * RemixSquareTone: a square wave tone generator
 *
 * <NAME> <<EMAIL>>, August 2001
 */

#define __REMIX__
#include "remix.h"

typedef struct _RemixSquareToneChannel RemixSquareToneChannel;
typedef struct _RemixSquareTone RemixSquareTone;

struct _RemixSquareToneChannel {
  RemixCount _cycle_offset;
};

struct _RemixSquareTone {
  RemixBase base;
  float frequency;
  CDSet * channels;
};

/* Optimisation dependencies: none */
static RemixSquareTone * remix_squaretone_optimise (RemixEnv * env,
					      RemixSquareTone * squaretone);

static RemixSquareTone *
remix_squaretone_replace_channels (RemixEnv * env, RemixSquareTone * squaretone)
{
  RemixSquareToneChannel * sqch;
  CDSet * s, * channels = remix_get_channels (env);
  RemixCount offset = remix_tell (env, (RemixBase *)squaretone);

  cd_set_free_all (env, squaretone->channels);

  for (s = channels; s; s = s->next) {
    remix_dprintf ("[remix_squaretone_replace_channels] %p replacing channel %d\n",
		squaretone, s->key);
    sqch = (RemixSquareToneChannel *)
      remix_malloc (sizeof (struct _RemixSquareToneChannel));
    sqch->_cycle_offset = 0;
    squaretone->channels =
      cd_set_insert (env, squaretone->channels, s->key, CD_POINTER(sqch));
  }

  if (offset > 0) remix_seek (env, (RemixBase *)squaretone, offset, SEEK_SET);

  return squaretone;
}

static RemixBase *
remix_squaretone_init (RemixEnv * env, RemixBase * base)
{
  RemixSquareTone * squaretone = (RemixSquareTone *)base;
  squaretone->channels = NULL;
  remix_squaretone_replace_channels (env, squaretone);
  remix_squaretone_optimise (env, squaretone);
  return base;
}

RemixBase *
remix_squaretone_new (RemixEnv * env, float frequency)
{
  RemixSquareTone * squaretone =
    (RemixSquareTone *)remix_base_new_subclass (env, sizeof (struct _RemixSquareTone));
  remix_squaretone_init (env, (RemixBase *)squaretone);
  squaretone->frequency = frequency;

  return (RemixBase *)squaretone;
}

static RemixBase *
remix_squaretone_clone (RemixEnv * env, RemixBase * base)
{
  RemixSquareTone * squaretone = (RemixSquareTone *)base;
  RemixSquareTone * new_squaretone =
    remix_squaretone_new (env, squaretone->frequency);
  remix_squaretone_optimise (env, new_squaretone);
  return (RemixBase *)new_squaretone;
}

static int
remix_squaretone_destroy (RemixEnv * env, RemixBase * base)
{
  RemixSquareTone * squaretone = (RemixSquareTone *)base;
  remix_free (squaretone);
  return 0;
}
<commit_msg>fix compile warning in remix_squaretone.c<commit_after>/*
 * libremix -- An audio mixing and sequencing library.
 *
 * Copyright (C) 2001 Commonwealth Scientific and Industrial Research
 * Organisation (CSIRO), Australia.
 *
 * 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 of the License, or (at your option) any later version.
 *
 * This library 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
 *
 */

/*
 * RemixSquareTone: a square wave tone generator
 *
 * <NAME> <<EMAIL>>, August 2001
 */

#define __REMIX__
#include "remix.h"

typedef struct _RemixSquareToneChannel RemixSquareToneChannel;
typedef struct _RemixSquareTone RemixSquareTone;

struct _RemixSquareToneChannel {
  RemixCount _cycle_offset;
};

struct _RemixSquareTone {
  RemixBase base;
  float frequency;
  CDSet * channels;
};

/* Optimisation dependencies: none */
static RemixSquareTone * remix_squaretone_optimise (RemixEnv * env,
					      RemixSquareTone * squaretone);

static RemixSquareTone *
remix_squaretone_replace_channels (RemixEnv * env, RemixSquareTone * squaretone)
{
  RemixSquareToneChannel * sqch;
  CDSet * s, * channels = remix_get_channels (env);
  RemixCount offset = remix_tell (env, (RemixBase *)squaretone);

  cd_set_free_all (env, squaretone->channels);

  for (s = channels; s; s = s->next) {
    remix_dprintf ("[remix_squaretone_replace_channels] %p replacing channel %d\n",
		squaretone, s->key);
    sqch = (RemixSquareToneChannel *)
      remix_malloc (sizeof (struct _RemixSquareToneChannel));
    sqch->_cycle_offset = 0;
    squaretone->channels =
      cd_set_insert (env, squaretone->channels, s->key, CD_POINTER(sqch));
  }

  if (offset > 0) remix_seek (env, (RemixBase *)squaretone, offset, SEEK_SET);

  return squaretone;
}

static RemixBase *
remix_squaretone_init (RemixEnv * env, RemixBase * base)
{
  RemixSquareTone * squaretone = (RemixSquareTone *)base;
  squaretone->channels = NULL;
  remix_squaretone_replace_channels (env, squaretone);
  remix_squaretone_optimise (env, squaretone);
  return base;
}

RemixBase *
remix_squaretone_new (RemixEnv * env, float frequency)
{
  RemixSquareTone * squaretone =
    (RemixSquareTone *)remix_base_new_subclass (env, sizeof (struct _RemixSquareTone));
  remix_squaretone_init (env, (RemixBase *)squaretone);
  squaretone->frequency = frequency;

  return (RemixBase *)squaretone;
}

static RemixBase *
remix_squaretone_clone (RemixEnv * env, RemixBase * base)
{
  RemixSquareTone * squaretone = (RemixSquareTone *)base;
  RemixBase * new_squaretone =
    remix_squaretone_new (env, squaretone->frequency);
  remix_squaretone_optimise (env, (RemixSquareTone *)new_squaretone);
  return new_squaretone;
}

static int
remix_squaretone_destroy (RemixEnv * env, RemixBase * base)
{
  RemixSquareTone * squaretone = (RemixSquareTone *)base;
  remix_free (squaretone);
  return 0;
}

{'fraction_non_alphanumeric': 0.0894752358490566, 'fraction_numerical': 0.0076650943396226415, 'mean_word_length': 4.789249146757679, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, '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': '2952964', 'n_tokens_mistral': 2389, 'n_tokens_neox': 2184, 'n_words': 648}