1// abc2svg - ABC to SVG translator 2// @source: https://chiselapp.com/user/moinejf/repository/abc2svg 3// Copyright (C) 2014-2020 Jean-Francois Moine - LGPL3+ 4//grid2.js-module to replace a voice in the music by a chord grid 5abc2svg.grid2={do_grid:function(){var s,v,p_v,ix,cs,c_a_cs,bt,voice_tb=this.get_voice_tb() 6for(v=0;v<voice_tb.length;v++){p_v=voice_tb[v] 7if(!p_v.grid2) 8continue 9p_v.clef.invis=true;p_v.key.k_sf=p_v.key.k_a_acc=0;p_v.staffnonote=2 10for(s=p_v.sym;s;s=s.next){delete s.a_dd 11if(!s.dur){if(s.bar_type) 12bt=s.time 13continue} 14s.invis=true;delete s.sl1;delete s.tie_s 15for(ix=0;ix<=s.nhd;ix++) 16delete s.notes[ix].tie_ty 17if(s.tf) 18s.tf[0]=1 19if(!s.a_gch){if(s.time==bt) 20s.a_gch=c_a_cs 21continue} 22for(ix=0;ix<s.a_gch.length;ix++){gch=s.a_gch[ix] 23if(gch.type=='g'){c_a_cs=s.a_gch 24break}}}}},draw_gchord:function(of,i,s,x,y){var an 25if(s.p_v.grid2){this.set_dscale(s.st) 26an=s.a_gch[i] 27if(an.type=='g'){this.use_font(an.font) 28this.set_font(an.font) 29this.xy_str(s.x+an.x,12-an.font.size*.5,an.text)}}else{of(i,s,x,y)}},output_music:function(of){abc2svg.grid2.do_grid.call(this);of()},set_fmt:function(of,cmd,param){if(cmd=="grid2"){var curvoice=this.get_curvoice() 30if(curvoice){this.set_v_param("stafflines","...");curvoice.grid2=param} 31return} 32of(cmd,param)},set_hooks:function(abc){abc.draw_gchord=abc2svg.grid2.draw_gchord.bind(abc,abc.draw_gchord);abc.output_music=abc2svg.grid2.output_music.bind(abc,abc.output_music);abc.set_format=abc2svg.grid2.set_fmt.bind(abc,abc.set_format)}} 33abc2svg.modules.hooks.push(abc2svg.grid2.set_hooks);abc2svg.modules.grid2.loaded=true 34