I was thinknig as much, I just tried:
giTest ftgen 1, 0, sr*1000, 7, 0, sr*1000, 7
instr 1
print ftlen(giTest)
endin
And it seemed to work fine
I was thinknig as much, I just tried:
giTest ftgen 1, 0, sr*1000, 7, 0, sr*1000, 7
instr 1
print ftlen(giTest)
endin
And it seemed to work fine
The error is here but I donāt see it.
Tomorrow Iāll have a look more closer to the GetData method.
public static MYFLT[] GetSamples(string source, SamplesOrigin origin)
{
MYFLT[] res = new MYFLT[0];
switch (origin)
{
case SamplesOrigin.Resources:
var src = Resources.Load<AudioClip>(source);
if (src == null)
{
res = null;
break;
}
var data = new float[src.samples];
src.GetData(data, 0);
res = new MYFLT[src.samples];
var s = 0;
foreach (var d in data)
{
res[s] = (MYFLT)d;
s++;
}
break;
case SamplesOrigin.StreamingAssets:
break;
case SamplesOrigin.Absolute:
break;
}
return res;
}
Did you push the fix for this?
Not yet.
Simply I forgot to multiply by samples length when getting the channels!
https://docs.unity3d.com/ScriptReference/AudioClip.GetData.html
float[] samples = new float[audioSource.clip.samples * audioSource.clip.channels];
audioSource.clip.GetData(samples, 0);
Pushing in a couple of mins to the develop branch ok?
Sure. Iām just going to look at that UDO idea now when I get a chanceā¦
I just pushed the fix, also fixed the logging (activating / deactivating wasnāt working)
Great. Thanks for this. I just noticed the following:
public int CreateTable(int tableNumber, MYFLT[] samples/*, int nChannels*/)
{
if (samples.Length < 1) return -1;
var resTable = CreateTableInstrument(tableNumber, samples.Length);
if (resTable != 0)
return -1;
// copy samples to the newly created table
CopyTableIn(tableNumber, samples);
return resTable;
}
public void CreateTable(int tableNumber, float[] samples/*, int nChannels*/)
{
MYFLT[] fltSamples = new MYFLT[samples.Length];
for (var i = 0; i < samples.Length; i++)
{
fltSamples[i] = (MYFLT)samples[i];
}
CreateTable(tableNumber, fltSamples/*, nChannels*/);
}
Can they not be merged into a single function?
Or is only one being called?
[edit] Got it. Only the top one is being used now right?
Yes, but the first is double float precision while the second is single precision. Only the first is used since we get floats from GetData usually.
But like this you can use the CreateTable with MYFLT samples, too
You get the data with GetData()
but in a function getSamples()
that always returns MYFLT
?
Yes but not always
Sometimes the user could have a stream of floats, and he couldnāt be aware about the MYFLT detail
Ok, but Csound will convert all numbers to MYFLT, regardless of what the user wants. There is no way to write floats to a table in Csound is MYFLT is set to double. All Unity audio data is float right?
Yes I think so.
Donāt know, maybe we could get rid of the two functions, since basically the second could be turned into a converter of samples
Itās not a big deal, just found it confusing. Anyway, for now Iām about to make some changes to the GetSamples() function so we set the number of channelsā¦ Youāll probably have to edit this after!
Ok great!
My csd file is not updating however? Each time I make a change on disk I have to drag it across in Unity again? Iām on Windows if that makes any difference?
I think the FileWatcher is not enabled.
Try putting FILEWATCHER_ON in the scripting define symbols in Player Settings
That did it thanks!
Do you experience a crash when quitting the Unity Editor?
I just had a crash now, but canāt tell why, or what did it. Let me try againā¦
Looks like setting FILEWATCHER_ON is what caused the crash for me