I’m wondering if someone might help me with a problem that has me stumped. I’m new to Scala, but have some experience with c, Pascal and Erlang.
I’m writing some music software and have a class called ‘Note’. It is constructed as:
class Note (
var delta: Int = 0, // time until event occurs
var pitch: Int = 0, // middle C = 60
var velocity: Int = 0, // amplitude corresponds to MIDI velocity
var duration: Int = 0,
var panposition: Int = 0
I need to construct a two-dimensional data structure that has two different types: one, an Int, so that I can access the musical track as 0, 1 etc. – and the other, a mutable list of notes as shown above.
Conceptually, the is would be: Array[Int][Note]
Clearly an Array.ofDim doesn’t work as the types are different and I’ve feel like I’m groping in the dark with ListBuffers, tuples, etc. Any suggestion as to how to do this would be most welcome.