if ($pitch->length) {
                        // it's a note
                        $noteObject->type = "note";
                        $noteObject->pitch = new stdClass();