/*
	Copyright (C) 2024-2025 Mark Tyler

	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 3 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 in the file COPYING.
*/

#include <mtdatawell_math.h>

#include "mtwasp.h"



void mtWasp::Sample::set_wave_buf (
	short	* const	buf,
	size_t	const	samples
	)
{
	free ( m_wave_buf );
	m_wave_buf = buf;
	m_wave_buf_samples = samples;
}

short * mtWasp::Sample::get_wave_buf ( size_t const samples )
{
	if ( samples < 1 )
	{
		return nullptr;
	}

	if ( samples == m_wave_buf_samples )
	{
		return m_wave_buf;
	}

	short * buf = (short *) malloc( samples * sizeof(*buf) );
	if ( ! buf )
	{
		return nullptr;
	}

	set_wave_buf ( buf, samples );

	return buf;
}

