sample editor workkkkkkk
This commit is contained in:
parent
c59c176de2
commit
689ed3bf65
9 changed files with 221 additions and 7 deletions
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "dataErrors.h"
|
||||
#include "song.h"
|
||||
#include <functional>
|
||||
#define _USE_MATH_DEFINES
|
||||
#include "engine.h"
|
||||
#include "instrument.h"
|
||||
|
|
@ -2275,6 +2276,12 @@ bool DivEngine::switchMaster() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void DivEngine::synchronized(const std::function<void()>& what) {
|
||||
isBusy.lock();
|
||||
what();
|
||||
isBusy.unlock();
|
||||
}
|
||||
|
||||
TAAudioDesc& DivEngine::getAudioDescWant() {
|
||||
return want;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "safeWriter.h"
|
||||
#include "../audio/taAudio.h"
|
||||
#include "blip_buf.h"
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
|
@ -244,7 +245,6 @@ class DivEngine {
|
|||
bool perSystemEffect(int ch, unsigned char effect, unsigned char effectVal);
|
||||
bool perSystemPostEffect(int ch, unsigned char effect, unsigned char effectVal);
|
||||
void recalcChans();
|
||||
void renderSamples();
|
||||
void reset();
|
||||
void playSub(bool preserveDrift, int goalRow=0);
|
||||
|
||||
|
|
@ -587,6 +587,9 @@ class DivEngine {
|
|||
// get register cheatsheet
|
||||
const char** getRegisterSheet(int sys);
|
||||
|
||||
// UNSAFE render samples - only execute when locked
|
||||
void renderSamples();
|
||||
|
||||
// public render samples
|
||||
void renderSamplesP();
|
||||
|
||||
|
|
@ -614,6 +617,9 @@ class DivEngine {
|
|||
// switch master
|
||||
bool switchMaster();
|
||||
|
||||
// perform secure/sync operation
|
||||
void synchronized(const std::function<void()>& what);
|
||||
|
||||
// get audio desc want
|
||||
TAAudioDesc& getAudioDescWant();
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,35 @@ bool DivSample::init(unsigned int count) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DivSample::resize(unsigned int count) {
|
||||
if (depth==8) {
|
||||
if (data8!=NULL) {
|
||||
signed char* oldData8=data8;
|
||||
data8=NULL;
|
||||
initInternal(8,count);
|
||||
memcpy(data8,oldData8,MIN(count,samples));
|
||||
delete[] oldData8;
|
||||
} else {
|
||||
initInternal(8,count);
|
||||
}
|
||||
samples=count;
|
||||
return true;
|
||||
} else if (depth==16) {
|
||||
if (data16!=NULL) {
|
||||
short* oldData16=data16;
|
||||
data16=NULL;
|
||||
initInternal(16,count);
|
||||
memcpy(data16,oldData16,sizeof(short)*MIN(count,samples));
|
||||
delete[] oldData16;
|
||||
} else {
|
||||
initInternal(16,count);
|
||||
}
|
||||
samples=count;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DivSample::render() {
|
||||
// step 1: convert to 16-bit if needed
|
||||
if (depth!=16) {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,14 @@ struct DivSample {
|
|||
*/
|
||||
bool init(unsigned int count);
|
||||
|
||||
/**
|
||||
* resize sample data. make sure the sample has been initialized before doing so.
|
||||
* @warning do not attempt to resize a sample outside of a synchronized block!
|
||||
* @param count number of samples.
|
||||
* @return whether it was successful.
|
||||
*/
|
||||
bool resize(unsigned int count);
|
||||
|
||||
/**
|
||||
* initialize the rest of sample formats for this sample.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue