The application for a new trial must be made and determined before judgment, the making of an order granting probation, the commitment of a defendant for observation as a mentally disordered sex offender, or the commitment of a defendant for narcotics addiction or insanity, whichever first occurs, and the order granting or denying the application shall be immediately entered by the clerk in the minutes.