FMOD Get Parameter OK, Set Parameter ERR_INVALID_PARAM - fmod

I have code that gets a parameter and then sets a parameter. The get works fine, but the set returns ERR_INVALID_PARAM:
FMOD.RESULT getResult = FMODManager.GetCurrentMusicInstance().getParameterByName(PianoVolumeParamter, out pianoParameter);
Debug.Log("Get Result " + getResult);
FMOD.RESULT result = FMODManager
.GetCurrentMusicInstance()
.setParameterByName(PianoVolumeParamter, 1f);
Debug.Log("Set Result " + result);
What am I doing wrong? This is FMOD for Unity 2.01.07. The max value for PianoVolume is 1f, the min is 0f. It's a continuous parameter.

So I'd accidentally set the parameter type to Global and you can't change Global parameters this way. Totally my mistake.

Related

Flutter: DropDownMenuItem - How to access i or index

I am trying to access my counter variable i OR the current index of the current item, but it seems impossible.
items: listeZutatenDropdown[i].map((String value) {
return DropdownMenuItem(
value: value,
child: (value == "Zutat auswählen") ? new Text("Zutat auswählen") : new Text(value + " " + i.toString()),
);
}).toList()
If I print i out as I do in my code example, I always get 0. (does that have to do with the scope of the return statement?).
If I try to use index as additional parameter, I get "The argument type 'List' can't be assigned to the parameter type 'List<DropdownMenuItem>?'" and "The argument type 'List' can't be assigned to the parameter type 'List<DropdownMenuItem>?'.dart(argument_type_not_assignable)
The argument type 'DropdownMenuItem Function(int, String)' can't be assigned to the parameter type 'dynamic Function(String)'" which confuses me because I see people using the .map() method as well as the .forEach() method all the time, but when I want to use them....^^
Lastly, I tried to save i in a variable and to access this variable in my return statement. Same outcome as before (0).
Hope you can tell me what I am doing wrong! Looking forward to your feedback!
Regards
Thomas
Since I was not able to access my counter variable nor the index, I just copied the code I already had for my listZutatenDropdown
listeZutatenDropdown = List<List<String>>.generate(listZutaten.length, (i) => List<String>.generate(listZutaten.length, (i) => listZutaten[i]));
and added the list of units
listeZutatenUndEinheiten = List<List<String>>.generate(listZutaten.length, (i) => List<String>.generate(listZutaten.length, (i) => listZutaten[i] + " (" + listEinheiten[i] + ")"));
Not the cleanest way in my opinion, because I would prefer to go with the counter variable OR the index to reduance unnecessary code, but it works.

Confusion with Null safety

I'm pretty new to flutter and because of the null safety feature I've been getting a lot of errors from a code that will run perfectly fine in Java or other langs. For example this-
int ? i;
var icecreamFlavours = ['chocolate', 'vanilla', 'orange'];
icecreamFlavours.forEach((item) {
i++; //This is where I get the error
print('We have the $item flavour');
});
My Error Message
Error: Operator '+' cannot be called on 'int?' because it is potentially null.
i++;
Error: A value of type 'num' can't be assigned to a variable of type 'int?'.
i++;
You can't do either i++ or i+=1 on a nullable variable, because the reason is simple, null variable can have null values which will make increment no sense.
In addition to this, you can't even do i!++ or i!+=1 even if you are sure that i is not null. There is an open issue for this https://github.com/dart-lang/language/issues/1113
So for now you can do this i = i! + 1
Update:
For i = i! + 1 to work you need to be sure about i not being null. So it's better to initialise/assign i with some value before using it.

Does setValueAtTime has a specific duration?

In the docs says:
The setValueAtTime() method of the AudioParam interface schedules an instant change to the AudioParam value at a precise time, as measured against AudioContext.currentTime. The new value is given in the value parameter.
From what one can think it makes an instant change but when a run this code
...
biquadNode.gain.setValueAtTime(12, this._AudioContext.currentTime);
console.log("biquadNode.gain " + biquadNode.gain.value);
console.log("biquadNode.frequency " + biquadNode.frequency.value);
setTimeout(() => {
console.log("biquadNode.gain " + biquadNode.gain.value);
console.log("biquadNode.frequency " + biquadNode.frequency.value);
}, 100);
...
It outputs:
0
12
I am not sure why...
It's instant, right, yet asynchronous (and is assumed to be a non-blocking op), as it's executed in a separate thread - note the word schedules in the description. That's why you won't see the change immediately.
Note that another method of updating value, via direct assignment to the corresponding property...
biquadNode.gain.value = 12;
... isn't synchronous either - and is basically equivalent to setValueAtTime(newValue, currentTime), as explained in this issue.

FakeItEasy ReturnsLazily with out parameter

I'm new to using FakeItEasy and rather stuck at my first attempt. The interface i want to fake has a method like this:
byte[] ReadFileChunk(string path,int offset,int count,out long size);
I would like to see how the arguments are passed on, so I'm using ReturnsLazily. Here is my attempt:
long resSize;
A.CallTo(() => dataAttributesController
.ReadFileChunk(A<string>.Ignored, A<int>.Ignored, A<int>.Ignored, out resSize))
.ReturnsLazily((string path, int offset, int count) =>
{
return Encoding.UTF8.GetBytes("You requested: " + path + "(" + offset + "," + count + ")");
})
.AssignsOutAndRefParameters(123);
This compiles, but when ran it generates this exception:
The faked method has the signature (System.String, System.Int32, System.Int32, System.Int64&), but returns lazily was used with (System.String, System.Int32, System.Int32).
Which is correct, but i can't figure out how to add the out parameter. If I change the ReturnLazily part to this:
.ReturnsLazily((string path, int offset, int count, out long size) =>
{
size = 0;
return Encoding.UTF8.GetBytes("You requested: " + path + "(" + offset + "," + count + ")");
})
it will not compile, and I don't understand the errors:
error CS1593: Delegate 'System.Func<FakeItEasy.Core.IFakeObjectCall,byte[]>' does not take 4 arguments
error CS1661: Cannot convert lambda expression to delegate type 'System.Func<string,int,int,long,byte[]>' because the parameter types do not match the delegate parameter types
error CS1677: Parameter 4 should not be declared with the 'out' keyword
For a novice like me, this reads like it doesn't like 4 parameters nor understands what to do with 'out'. Can someone please explain me how I should be reading these errors? A working example would be very welcome as well :-)
Thanks a lot!
--- EDIT ---
This seems to work:
A.CallTo(() => dataAttributesController
.ReadFileChunk(A<string>.Ignored, A<int>.Ignored, A<int>.Ignored, out resSize))
.ReturnsLazily(x =>
Encoding.UTF8.GetBytes("You requested: " + x.Arguments.Get<string>(0) + "(" + x.Arguments.Get<int>(1) + "," + x.Arguments.Get<int>(2) + ")"))
.AssignsOutAndRefParameters((long)123);
A bit less readable then I was hoping for, is this anywhere near the intended use of ReturnsLazily?
Is that interface under your control?
byte[] ReadFileChunk(string path, int offset, int count, out long size);
if so: Isn't out long size just the same as the size of the returning byte[]?
In that case I would just remove the size parameter from the interface method and use the "nice-to-read" ReturnsLazily method as you intended first.
Update: the issue I mention below was fixed in FakeItEasy release 1.15, so update to the latest version and you shouldn't have to worry about the out/ref specifiers on the methods when using ReturnsLazily.
Sorry for the delay. I'm glad you found a solution that at least functions for you.
I agree that the syntax you landed on isn't the most readable, but it does appear to be the correct one. The "convenience" versions of ReturnsLazily won't work with out/ref parameters because the lambda can't take the out/ref modifiers.
It doesn't help you today, but I've created FakeItEasy issue 168 to deal with the problem. If you have additional opinions, please drop by and comment or something.

AMFPHP overiding default function arguments?

I've got this odd problem.
If I make a call on that function through amfphp service browser and give it a valid ID and leave the $num_images field blank amfphp will actually pass a blank string as the argument.
// if i call this function width just an ID
function getWorkers($id, $num_images = 100) {
...
// num_images will be set as ''
}
I can easily override using a check:
function getWorkers($id, $num_images = 100) {
if($num_images=='') $num_images = 100;
...
// num_images will now be really set as 100
}
Anyone experiencing the same with amfphp?
That's odd, I never got that from AMFPHP. If you don't have the latest version try updating your installation of AMFPHP. Also make sure Flash doesn't somehow pass an empty variable as the second variable.
(Copied from the comment.)