Hi Jakob,

Jakob Lund wrote:
> The "zomby" version can indeed produce sounds. But it seems to load all the 
> different values with wrong numbers. After loading a song, going to the mixer 
> and turning up the instrument- and master faders, going to the pattern view 
> and adjusting the velocity AND pan, I managed to get some of the notes to 
> play.

Thanks for testing this out!  I'll look in to these today.  (I've been on 
vacation all week... but didn't want to announce it to the internet...)

> Every note that gets played still causes a `new Note` being issued in 
> hydrogen.cpp -- am I right that this is potentially a problem? If so, we 

Yes, but it's been low on the priority list because it's not known to create a 
problem.  Also, std::vector<> (and maybe std::dequeue<>) has a block of memory 
pre-allocated (and larger than the vector).  So, it's usually only a problem if 
you exceed that storage range.

> Also, there's a very old patch of mine (attached) that I think ought to be 
> considered for this branch (there is a priority queue of Note*'s using 
> comparison of Note&'s, and I _suspect_ this causes the Note( Note* ) 
> constructor to take effect "behind the scenes" -- this is C++, right? )

No, passing a Note& does not call any constructors.  Passing a reference is 
nearly identical to passing a pointer, except that:

    * You must be passing a valid instance of Note

    * You access the values using '.' instead of
      pointer dereferencing '->'.

    * You can not construct, delete, or recreate
      the Note inside the function.

However, in reality, it's actually the pointer that is being passed on the 
stack 
to the function.  The following two are nearly identical at the machine level:

class Dog;

void walk_dog_p( const Dog* d) {
     d->walk();
}

void walk_dog_r( const Dog& d) {
     d.walk();
}

Dog& requires that there actually be an instance of Dog.  Passing a Dog* will 
allow you to pass a null or invalid pointer.  However, using Dog& will _not_ 
call the Dog::Dog() constructor.

You can also use references instead of pointers when doing forward 
declarations. 
  You probably know that you can do this in a header:

class Dog;

class Kennel {
public:
     void add_dog(const Dog* d);
     Dog* find_dog(const char* name);
};

This will compile even though you haven't declared the 'Dog' class.  In fact, 
Dog can be an opaque type that isn't even known until run-time.  The following 
does the same thing with references, and will also compile without knowing what 
'Dog' is:

class Dog;

class Kennel {
public:
     void add_dog(const Dog& d);
     Dog& find_dog(const char* name);
}

As said before, the difference is that 'd' and the return of find_dog() must be 
a real instance of the object.  (I.e. no null pointers.)

I will often use references instead of pointers because (a) I like to use '.' 
notation rather than '->' pointer dereferencing and (b) you don't have to 
constantly test to see if someone passed you a null or invalid pointer.

> Hugs
>  -- Jakob

Kisses,
Gabriel


------------------------------------------------------------------------------
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel

Reply via email to