Changeset 6707

Show
Ignore:
Timestamp:
07/01/09 14:15:47 (9 months ago)
Author:
smimram
Message:

synth.all.

Location:
trunk/liquidsoap/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/liquidsoap/src/formats/midiformat.ml

    r6705 r6707  
    310310    (* Filling function. *) 
    311311    let track = ref track in 
     312    let warn_channels = ref true in 
    312313    let fill buf = 
    313314      let m = MFrame.tracks buf in 
     
    319320        while !track <> [] && !offset_in_buf < buflen do 
    320321          let d,(c,e) = List.hd !track in 
    321             (* Printf.printf "delta: %d\n%!" d; *) 
    322322            offset_in_buf := !offset_in_buf + d; 
    323323            if !offset_in_buf < buflen then 
     
    330330                          | Midi.Note_on _ 
    331331                          | Midi.Note_off _ -> 
    332                               (* Printf.printf "EVENT (chan %d)!\n%!" c; *) 
    333                               m.(c) := !(m.(c))@[!offset_in_buf, e] 
     332                              ( 
     333                                try 
     334                                  m.(c) := !(m.(c))@[!offset_in_buf, e] 
     335                                with 
     336                                  | Invalid_argument _ -> 
     337                                      if !warn_channels then 
     338                                        ( 
     339                                          log#f 3 "Event on channel %d will be ignored, increase frame.midi.channels (this message is displayed only once)." c; 
     340                                          warn_channels := false 
     341                                        ) 
     342                              ) 
    334343                          | _ -> () (* TODO *) 
    335344                      ) 
  • trunk/liquidsoap/src/synth/synth.ml

    r6702 r6707  
    4646  method note_on n v = 
    4747    (* Limit the number of notes for now. TODO: parameter *) 
    48     if List.length notes > 16 then notes <- List.rev (List.tl (List.rev notes)); 
     48    (* if List.length notes > 16 then notes <- List.rev (List.tl (List.rev notes)); *) 
    4949    notes <- (n, ref (self#note_init n v))::notes 
    5050 
  • trunk/liquidsoap/src/synth/synth_op.ml

    r6701 r6707  
    3434  method remaining = source#remaining 
    3535 
    36   method is_ready = 
    37     source#is_ready 
     36  method is_ready = source#is_ready 
    3837 
    3938  method abort_track = source#abort_track 
     
    4443    let evs = !evs in 
    4544    source#get buf; 
     45    if blankify then AFrame.blankify buf offset (AFrame.size buf - offset); 
    4646    let b = AFrame.get_float_pcm buf in 
    4747    let position = AFrame.position buf in 
     
    6969    [ 
    7070      "channel", Lang.int_t, Some (Lang.int 0), Some "MIDI channel to handle."; 
    71       "volume", Lang.float_t, Some (Lang.float 0.3), Some "Volume."; 
     71      "volume", Lang.float_t, Some (Lang.float 0.3), Some "Initial volume."; 
    7272      "", Lang.source_t, None, None 
    7373    ] 
     
    7979       let volume = Lang.to_float (f "volume") in 
    8080       let src = Lang.to_source (f "") in 
    81          new synth (obj ()) src chan volume) 
     81         new synth (obj ()) src chan volume); 
     82  Lang.add_operator ("synth.all." ^ name) 
     83    [ 
     84      "", Lang.source_t, None, None 
     85    ] 
     86    ~category:Lang.SoundSynthesis 
     87    ~descr:(descr ^ " It creates one synthesizer for each channel.") 
     88    (fun p _ -> 
     89       let f v = List.assoc v p in 
     90       let src = Lang.to_source (f "") in 
     91       let synths = Array.init (Fmt.midi_channels ()) (fun c -> 1, new synth (obj ()) src c 1.) in 
     92       let synths = Array.to_list synths in 
     93         new Add.add ~renorm:false synths 
     94           (fun _ -> ()) 
     95           (fun _ buf tmp -> RGB.add buf tmp) 
     96    ) 
    8297 
    83 let () = register (fun () -> (new Synth.sine :> Synth.synth)) "sine" "Sine synthesiser." 
    84 let () = register (fun () -> (new Synth.square :> Synth.synth)) "square" "Square synthesiser." 
    85 let () = register (fun () -> (new Synth.saw :> Synth.synth)) "saw" "Saw synthesiser." 
     98let () = register (fun () -> (new Synth.sine :> Synth.synth)) "sine" "Sine synthesizer." 
     99let () = register (fun () -> (new Synth.square :> Synth.synth)) "square" "Square synthesizer." 
     100let () = register (fun () -> (new Synth.saw :> Synth.synth)) "saw" "Saw synthesizer." 
  • trunk/liquidsoap/src/visualization/midimeter.ml

    r6701 r6707  
    4646                 | _ -> "???" 
    4747             in 
    48                Printf.printf "%d: %s.\n%!" c s 
     48               Printf.printf "%02d: %s.\n%!" c s 
    4949          ) !(m.(c)) 
    5050      done