Merge pull request #153 from wongcc966422/sfxr

LMMS port of sfxr
This commit is contained in:
Tobias Doerffel
2014-01-25 11:30:16 -08:00
26 changed files with 1535 additions and 0 deletions

View File

@@ -481,6 +481,14 @@ sf2InstrumentView knob {
qproperty-lineWidth: 2;
}
sfxrInstrumentView knob {
color: #b06319;
qproperty-outerColor: rgb(194, 177, 145);
qproperty-innerRadius: 2;
qproperty-outerRadius: 10;
qproperty-lineWidth: 2;
}
opl2instrumentView knob {
color: rgb(128,128,128);
qproperty-outerColor: rgb(255,255,255);

View File

@@ -15,6 +15,7 @@ ADD_SUBDIRECTORY(papu)
ADD_SUBDIRECTORY(patman)
ADD_SUBDIRECTORY(peak_controller_effect)
ADD_SUBDIRECTORY(sf2_player)
ADD_SUBDIRECTORY(sfxr)
ADD_SUBDIRECTORY(sid)
ADD_SUBDIRECTORY(spectrum_analyzer)
ADD_SUBDIRECTORY(stereo_enhancer)

View File

@@ -0,0 +1,3 @@
INCLUDE(BuildPlugin)
BUILD_PLUGIN(sfxr sfxr.cpp sfxr.h MOCFILES sfxr.h EMBEDDED_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.png)

BIN
plugins/sfxr/artwork.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

BIN
plugins/sfxr/hit_active.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
plugins/sfxr/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

170
plugins/sfxr/readme.txt Normal file
View File

@@ -0,0 +1,170 @@
This is a port of sfxr to LMMS, ported by Wong Cho Ching.
NOTE: Do NOT remove the MIT license below to prevent legal problem.
Original Readme File:
(http://www.drpetter.se/project_sfxr.html)
-----------------------------
sfxr - sound effect generator
-----------------------------
by DrPetter, 2007-12-14
developed for LD48#10
-----------------------------
Basic usage:
Start the application, then hit
some of the buttons on the left
side to generate random sounds
matching the button descriptions.
Press "Export .WAV" to save the
current sound as a WAV audio file.
Click the buttons below to change
WAV format in terms of bits per
sample and sample rate.
If you find a sound that is sort
of interesting but not quite what
you want, you can drag some sliders
around until it sounds better.
The Randomize button generates
something completely random.
Mutate slightly alters the current
parameters to automatically create
a variation of the sound.
Advanced usage:
Figure out what each slider does and
use them to adjust particular aspects
of the current sound...
Press the right mouse button on a slider
to reset it to a value of zero.
Press Space or Enter to play the current sound.
The Save/Load sound buttons allow saving
and loading of program parameters to work
on a sound over several sessions.
Volume setting is saved with the sound and
exported to WAV. If you increase it too much
there's a risk of clipping.
Some parameters influence the sound during
playback (particularly when using a non-zero
repeat speed), and dragging these sliders
can cause some interesting effects.
To record this you will need to use an external
recording application, for instance Audacity.
Set the recording source in that application
to "Wave", "Stereo Mix", "Mixed Output" or similar.
Using an external sound editor to capture and edit
sound can also be used to string several sounds
together for more complex results.
Parameter description:
- The top four buttons select base waveform
- First four parameters control the volume envelope
Attack is the beginning of the sound,
longer attack means a smoother start.
Sustain is how long the volume is held constant
before fading out.
Increase Sustain Punch to cause a popping
effect with increased (and falling) volume
during the sustain phase.
Decay is the fade-out time.
- Next six are for controlling the sound pitch or
frequency.
Start frequency is pretty obvious. Has a large
impact on the overall sound.
Min frequency represents a cutoff that stops all
sound if it's passed during a downward slide.
Slide sets the speed at which the frequency should
be swept (up or down).
Delta slide is the "slide of slide", or rate of change
in the slide speed.
Vibrato depth/speed makes for an oscillating
frequency effect at various strengths and rates.
- Then we have two parameters for causing an abrupt
change in pitch after a ceratin delay.
Amount is pitch change (up or down)
and Speed indicates time to wait before changing
the pitch.
- Following those are two parameters specific to the
squarewave waveform.
The duty cycle of a square describes its shape
in terms of how large the positive vs negative
sections are. It can be swept up or down by
changing the second parameter.
- Repeat speed, when not zero, causes the frequency
and duty parameters to be reset at regular intervals
while the envelope and filter continue unhindered.
This can make for some interesting pulsating effects.
- Phaser offset overlays a delayed copy of the audio
stream on top of itself, resulting in a kind of tight
reverb or sci-fi effect.
This parameter can also be swept like many others.
- Finally, the bottom five sliders control two filters
which are applied after all other effects.
The first one is a resonant lowpass filter which has
a sweepable cutoff frequency.
The other is a highpass filter which can be used to
remove undesired low frequency hum in "light" sounds.
----------------------
License
-------
Basically, I don't care what you do with it, anything goes.
To please all the troublesome folks who request a formal license,
I attach the "MIT license" as follows:
--
Copyright (c) 2007 Tomas Pettersson
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------
http://www.drpetter.se
drpetter@gmail.com
----------------------

1052
plugins/sfxr/sfxr.cpp Normal file

File diff suppressed because it is too large Load Diff

301
plugins/sfxr/sfxr.h Normal file
View File

@@ -0,0 +1,301 @@
/*
* sfxr.h - declaration of classes of the LMMS sfxr plugin
* Originally written by Tomas Pettersson. For the original license,
* please read readme.txt in this directory
*
* Copyright (c) 2014 Wong Cho Ching
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _SFXR_H
#define _SFXR_H
#include "Instrument.h"
#include "InstrumentView.h"
#include "knob.h"
#include "graph.h"
#include "pixmap_button.h"
#include "led_checkbox.h"
enum SfxrWaves
{
SQR_WAVE, SAW_WAVE, SINE_WAVE, NOISE_WAVE, WAVES_NUM
};
const int WAVEFORM_BASE_X = 20;
const int WAVEFORM_BASE_Y = 14;
const int WAVEFORM_BUTTON_WIDTH = 16;
const int GENERATOR_BASE_X = 110;
const int GENERATOR_BASE_Y = 24;
const int GENERATOR_BUTTON_WIDTH = 16;
const int RAND_BUTTON_X = 160;
const int RAND_BUTTON_Y = 4;
const int MUTA_BUTTON_X = 205;
const int MUTA_BUTTON_Y = 4;
const int KNOBS_BASE_X = 20;
const int KNOBS_BASE_Y = 50;
const int KNOB_BLOCK_SIZE_X = 40;
const int KNOB_BLOCK_SIZE_Y = 40;
class sfxrInstrument;
class SfxrSynth
{
public:
SfxrSynth( const sfxrInstrument * s );
virtual ~SfxrSynth();
void resetSample( bool restart );
void update( sampleFrame * buffer, const fpp_t frameNum );
bool isPlaying() const;
private:
const sfxrInstrument * s;
bool playing_sample;
int phase;
double fperiod;
double fmaxperiod;
double fslide;
double fdslide;
int period;
float square_duty;
float square_slide;
int env_stage;
int env_time;
int env_length[3];
float env_vol;
float fphase;
float fdphase;
int iphase;
float phaser_buffer[1024];
int ipp;
float noise_buffer[32];
float fltp;
float fltdp;
float fltw;
float fltw_d;
float fltdmp;
float fltphp;
float flthp;
float flthp_d;
float vib_phase;
float vib_speed;
float vib_amp;
int rep_time;
int rep_limit;
int arp_time;
int arp_limit;
double arp_mod;
} ;
/**
* @brief A class that simplify the constructor of FloatModel, with value [0,1]
*/
class SfxrZeroToOneFloatModel : public FloatModel
{
public:
SfxrZeroToOneFloatModel(float val, Model * parent):
FloatModel( val, 0.0, 1.0, 0.001, parent)
{
}
/* purpose: prevent the initial value of the model from being changed */
virtual void loadSettings( const QDomElement& element, const QString& name = QString( "value" ) )
{
float oldInitValue = initValue();
FloatModel::loadSettings(element, name);
float oldValue = value();
setInitValue(oldInitValue);
setValue(oldValue);
}
};
/**
* @brief A class that simplify the constructor of FloatModel, with value [-1,1]
*/
class SfxrNegPosOneFloatModel : public FloatModel
{
public:
SfxrNegPosOneFloatModel(float val, Model * parent):
FloatModel( val, -1.0, 1.0, 0.001, parent)
{
}
/* purpose: prevent the initial value of the model from being changed */
virtual void loadSettings( const QDomElement& element, const QString& name = QString( "value" ) )
{
float oldInitValue = initValue();
FloatModel::loadSettings(element, name);
float oldValue = value();
setInitValue(oldInitValue);
setValue(oldValue);
}
};
class sfxrInstrument : public Instrument
{
Q_OBJECT
public:
sfxrInstrument(InstrumentTrack * _instrument_track );
virtual ~sfxrInstrument();
virtual void playNote( notePlayHandle * _n, sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName() const;
virtual PluginView * instantiateView( QWidget * _parent );
void resetModels();
private:
QMutex m_synthMutex;
SfxrZeroToOneFloatModel m_attModel;
SfxrZeroToOneFloatModel m_holdModel;
SfxrZeroToOneFloatModel m_susModel;
SfxrZeroToOneFloatModel m_decModel;
SfxrZeroToOneFloatModel m_startFreqModel;
SfxrZeroToOneFloatModel m_minFreqModel;
SfxrNegPosOneFloatModel m_slideModel;
SfxrNegPosOneFloatModel m_dSlideModel;
SfxrZeroToOneFloatModel m_vibDepthModel;
SfxrZeroToOneFloatModel m_vibSpeedModel;
SfxrNegPosOneFloatModel m_changeAmtModel;
SfxrZeroToOneFloatModel m_changeSpeedModel;
SfxrZeroToOneFloatModel m_sqrDutyModel;
SfxrNegPosOneFloatModel m_sqrSweepModel;
SfxrZeroToOneFloatModel m_repeatSpeedModel;
SfxrNegPosOneFloatModel m_phaserOffsetModel;
SfxrNegPosOneFloatModel m_phaserSweepModel;
SfxrZeroToOneFloatModel m_lpFilCutModel;
SfxrNegPosOneFloatModel m_lpFilCutSweepModel;
SfxrZeroToOneFloatModel m_lpFilResoModel;
SfxrZeroToOneFloatModel m_hpFilCutModel;
SfxrNegPosOneFloatModel m_hpFilCutSweepModel;
IntModel m_waveFormModel;
friend class sfxrInstrumentView;
friend class SfxrSynth;
};
class sfxrInstrumentView : public InstrumentView
{
Q_OBJECT
public:
sfxrInstrumentView( Instrument * _instrument,
QWidget * _parent );
virtual ~sfxrInstrumentView() {};
protected slots:
void genPickup();
void genLaser();
void genExplosion();
void genPowerup();
void genHit();
void genJump();
void genBlip();
void randomize();
void mutate();
private:
virtual void modelChanged();
knob * m_attKnob; //Attack Time
knob * m_holdKnob; //Sustain Time
knob * m_susKnob; //Sustain Punch
knob * m_decKnob; //Decay Time
knob * m_startFreqKnob; //Start Frequency
knob * m_minFreqKnob; //Min Frequency
knob * m_slideKnob; //Slide
knob * m_dSlideKnob; //Delta Slide
knob * m_vibDepthKnob; //Vibrato Depth
knob * m_vibSpeedKnob; //Vibrato Speed
knob * m_changeAmtKnob; //Change Amount
knob * m_changeSpeedKnob; //Change Speed
knob * m_sqrDutyKnob; //Squre Duty
knob * m_sqrSweepKnob; //Squre Sweep
knob * m_repeatSpeedKnob; //Repeat Speed
knob * m_phaserOffsetKnob; //Phaser Offset
knob * m_phaserSweepKnob; //Phaser Sweep
knob * m_lpFilCutKnob; //LP Filter Cutoff
knob * m_lpFilCutSweepKnob; //LP Filter Cutoff Sweep
knob * m_lpFilResoKnob; //LP Filter Resonance
knob * m_hpFilCutKnob; //HP Filter Cutoff
knob * m_hpFilCutSweepKnob; //HP Filter Cutoff Sweep
automatableButtonGroup * m_waveBtnGroup;
pixmapButton * m_sqrWaveBtn; //NOTE: This button has Squre Duty
//and Squre Speed configurable
pixmapButton * m_sawWaveBtn;
pixmapButton * m_sinWaveBtn;
pixmapButton * m_noiseWaveBtn;
pixmapButton * m_pickupBtn;
pixmapButton * m_laserBtn;
pixmapButton * m_explosionBtn;
pixmapButton * m_powerupBtn;
pixmapButton * m_hitBtn;
pixmapButton * m_jumpBtn;
pixmapButton * m_blipBtn;
pixmapButton * m_randomizeBtn;
pixmapButton * m_mutateBtn;
static QPixmap * s_artwork;
};
#endif