~ubuntu-branches/ubuntu/intrepid/tk707/intrepid

« back to all changes in this revision

Viewing changes to playa.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2004-07-25 23:44:01 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040725234401-cl4g3i2m3jvqdtdl
Tags: 0.7.21-9
* debian/control:
  + Set policy to 3.6.1.1.
  + Use tk8.4-dev instead of tk8.3-dev. Fixes strange disappearing of the
    STOP and START buttons (Closes: #205607).
  + Recommend timidity and make a comment about timidity in the long
    description (Closes: #229689).
* debian/menu:
  + Quoted strings where appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
                                break;
180
180
                        }
181
181
                        default:
182
 
                                fprintf(stderr, "unexpected short option `%c'\n", c);
183
182
                                usage();
 
183
                                Tcl_SetObjResult(interp, Tcl_NewIntObj(3));
184
184
                                return TCL_OK;
185
185
                                break;
186
186
                }
559
559
        TK707 *tk707 = (TK707*)clientData;
560
560
        seq707_context_t *ctxp = tk707->ctxp_p;
561
561
        int diff, newticks;
562
 
        snd_seq_queue_tempo_t   tempo;
563
562
        snd_seq_event_t ev;
564
563
        tk707_get_int1_macro(interp,objc,objv, newticks);
565
564
 
568
567
        ctxp->ppq = newticks;
569
568
        return TCL_OK;
570
569
}
 
570
#ifdef HAVE_SYS_ASOUNDLIB_H
571
571
int 
572
572
timer_status(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
573
573
{
591
591
        Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
592
592
        return TCL_OK;
593
593
}
 
594
#else /* !HAVE_SYS_ASOUNDLIB_H */
 
595
int 
 
596
timer_status(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 
597
{
 
598
        TK707 *tk707 = (TK707*)clientData;
 
599
        seq707_context_t *ctxp = tk707->ctxp_p;
 
600
        snd_seq_queue_status_t *status;
 
601
 
 
602
        snd_seq_queue_status_alloca(&status);
 
603
        snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, status);
 
604
        Tcl_SetObjResult(interp, Tcl_NewIntObj(snd_seq_queue_status_get_tick_time(status)));
 
605
 
 
606
return TCL_OK;
 
607
}
 
608
int 
 
609
get_pat_tick(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 
610
{
 
611
        TK707 *tk707 = (TK707*)clientData;
 
612
        seq707_context_t *ctxp = tk707->ctxp_p;
 
613
        snd_seq_queue_status_t *status;
 
614
        int result;
 
615
 
 
616
        snd_seq_queue_status_alloca(&status);
 
617
        snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, status);
 
618
        result = 16 - ((ctxp->currticktime - snd_seq_queue_status_get_tick_time(status))/old_tick_per_sixtennth);
 
619
        Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
 
620
 
 
621
return TCL_OK;
 
622
}
 
623
#endif /* HAVE_SYS_ASOUNDLIB_H */
594
624
static
595
625
int
596
626
ponderated_velocity (int volume_master, int volume_accent, double accent_factor,
635
665
 
636
666
        seq707_context_t *ctxp = tk707->ctxp_c;
637
667
        static int have_start = 0;
 
668
#ifdef HAVE_SYS_ASOUNDLIB_H
638
669
        snd_seq_queue_status_t status;
 
670
#else
 
671
        snd_seq_queue_status_t *status;
 
672
#endif
 
673
        int cur_tick;
639
674
        int midich;
640
675
 
 
676
#ifdef HAVE_SYS_ASOUNDLIB_H
641
677
        snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, &status);
642
 
        if ( status.tick > ctxp->currticktime ) {
643
 
            ctxp->currticktime = status.tick;
 
678
        cur_tick = status.tick;
 
679
#else
 
680
        snd_seq_queue_status_alloca(&status);
 
681
        snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, status);
 
682
        cur_tick = snd_seq_queue_status_get_tick_time(status);
 
683
#endif
 
684
        if ( cur_tick > ctxp->currticktime ) {
 
685
            ctxp->currticktime = cur_tick;
644
686
        }
645
687
        midich = ctxp->midichannel;
646
688
        if (!have_start) {
658
700
            ctxp->currticktime += tick_per_flam;
659
701
            do_noteon (ctxp, midich, midi_note, velocity);
660
702
        }
 
703
#ifdef HAVE_SYS_ASOUNDLIB_H
661
704
        snd_seq_flush_output(ctxp->handle);
 
705
#else
 
706
        snd_seq_drain_output(ctxp->handle);
 
707
#endif
662
708
}
663
709
static
664
710
void
665
711
c_stop_note (TK707 *tk707, int midi_note)
666
712
{       
667
713
        seq707_context_t *ctxp = tk707->ctxp_c;
 
714
#ifdef HAVE_SYS_ASOUNDLIB_H
668
715
        snd_seq_queue_status_t status;
 
716
#else
 
717
        snd_seq_queue_status_t *status;
 
718
#endif
 
719
        int cur_tick;
669
720
        int midich;
670
721
 
 
722
#ifdef HAVE_SYS_ASOUNDLIB_H
671
723
        snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, &status);
672
 
        if ( status.tick > ctxp->currticktime ) {
673
 
            ctxp->currticktime = status.tick;
 
724
        cur_tick = status.tick;
 
725
#else
 
726
        snd_seq_queue_status_alloca(&status);
 
727
        snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, status);
 
728
        cur_tick = snd_seq_queue_status_get_tick_time(status);
 
729
#endif
 
730
        if ( cur_tick > ctxp->currticktime ) {
 
731
            ctxp->currticktime = cur_tick;
674
732
        }
675
733
        midich = ctxp->midichannel;
676
734
 
677
735
        do_noteon (ctxp, midich, midi_note, 0);
678
736
        /* ctxp->currticktime += old_tick_per_quarter; */
679
737
 
 
738
#ifdef HAVE_SYS_ASOUNDLIB_H
680
739
        snd_seq_flush_output(ctxp->handle);
681
 
        /* snd_seq_drain_output(ctxp->handle); */
 
740
#else
 
741
        snd_seq_drain_output(ctxp->handle);
 
742
#endif
682
743
 
683
744
        alsa_timer_stop(ctxp);
684
745
}
741
802
{
742
803
        TK707 *tk707 = (TK707*)clientData;
743
804
        seq707_context_t *ctxp = tk707->ctxp_p;
 
805
#ifdef HAVE_SYS_ASOUNDLIB_H
744
806
        snd_seq_drain_output(ctxp->handle);
 
807
#else
 
808
        snd_seq_drop_output(ctxp->handle);
 
809
#endif
745
810
        return TCL_OK;
746
811
}
747
812
int 
749
814
{
750
815
    TK707 *tk707 = (TK707*)clientData;
751
816
    seq707_context_t *ctxp = tk707->ctxp_p;
 
817
#ifdef HAVE_SYS_ASOUNDLIB_H
752
818
    snd_seq_queue_status_t status;
 
819
#else
 
820
    snd_seq_queue_status_t *status;
 
821
#endif
 
822
    int cur_tick;
753
823
    int group, pattern, step, stepcount, scale, midich, dur;
754
824
    PatternElement *current_pattern;
755
825
    int volume_master, volume_accent, flam_interval;
770
840
        fprintf (stderr, "FATAL: invalid flam/delay configuration\n");
771
841
        exit (1);
772
842
    }
 
843
#ifdef HAVE_SYS_ASOUNDLIB_H
773
844
    snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, &status);
774
 
    if ( status.tick > ctxp->currticktime ) {
775
 
        ctxp->currticktime = status.tick;
 
845
    cur_tick = status.tick;
 
846
#else
 
847
    snd_seq_queue_status_alloca(&status);
 
848
    snd_seq_get_queue_status(ctxp->handle, ctxp->dest_queue, status);
 
849
    cur_tick = snd_seq_queue_status_get_tick_time(status);
 
850
#endif
 
851
    if ( cur_tick > ctxp->currticktime ) {
 
852
        ctxp->currticktime = cur_tick;
776
853
    }
777
854
    midich = ctxp->midichannel;
778
855
    alsa_timer_cont (ctxp);
823
900
        }
824
901
        ctxp->currticktime += old_tick_per_step_off_scale [scale];
825
902
    }
 
903
#ifdef HAVE_SYS_ASOUNDLIB_H
826
904
    snd_seq_flush_output(ctxp->handle);
 
905
#else
 
906
    snd_seq_drain_output(ctxp->handle);
 
907
#endif
827
908
    alsa_timer_stop(ctxp);
828
909
 
829
 
    dur = (int)(500*((double)(ctxp->currticktime - status.tick)/(double)ctxp->ppq));
 
910
    dur = (int)(500*((double)(ctxp->currticktime - cur_tick)/(double)ctxp->ppq));
830
911
    Tcl_SetObjResult(interp, Tcl_NewIntObj(dur - tick_per_step));
831
912
    return TCL_OK;
832
913
}
1014
1095
/*
1015
1096
        Construct a list of ALSA midi ports on the system.
1016
1097
*/
 
1098
#ifdef HAVE_SYS_ASOUNDLIB_H
1017
1099
int 
1018
1100
port_list(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
1019
1101
{
1061
1143
                                Tcl_ListObjAppendElement(interp, items[i],
1062
1144
                                                        Tcl_NewStringObj(pinfo.name, strlen(pinfo.name)));
1063
1145
                                Tcl_ListObjAppendElement(interp, items[i],
1064
 
                                                        Tcl_NewStringObj(cinfo.name, strlen(pinfo.name)));
1065
 
 
1066
 
                                Tcl_ListObjAppendElement(interp, res, items[i]);
1067
 
                                i++;
1068
 
                        }
1069
 
                }
1070
 
        }
1071
 
        
1072
 
        Tcl_SetObjResult(interp, res);
1073
 
 
1074
 
return TCL_OK;
1075
 
}
 
1146
                                                        Tcl_NewStringObj(cinfo.name, strlen(cinfo.name)));
 
1147
 
 
1148
                                Tcl_ListObjAppendElement(interp, res, items[i]);
 
1149
                                i++;
 
1150
                        }
 
1151
                }
 
1152
        }
 
1153
        
 
1154
        Tcl_SetObjResult(interp, res);
 
1155
 
 
1156
return TCL_OK;
 
1157
}
 
1158
#else /* !HAVE_SYS_ASOUNDLIB_H */
 
1159
int 
 
1160
port_list(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 
1161
{
 
1162
        TK707 *tk707 = (TK707*)clientData;
 
1163
        Tcl_Obj *res, *items[17]={NULL};
 
1164
        int i, client, port, io;
 
1165
        snd_seq_client_info_t *cinfo;
 
1166
        snd_seq_port_info_t *pinfo;
 
1167
        snd_seq_t *handle;
 
1168
        tk707_get_int1_macro(interp,objc,objv, io);
 
1169
 
 
1170
        if( snd_seq_open(&handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0 )
 
1171
        {
 
1172
                return TCL_ERROR;
 
1173
        }
 
1174
 
 
1175
        res = Tcl_NewListObj(0, NULL);
 
1176
 
 
1177
        snd_seq_client_info_alloca(&cinfo);
 
1178
        snd_seq_port_info_alloca(&pinfo);
 
1179
 
 
1180
        i = 0;
 
1181
        snd_seq_client_info_set_client(cinfo, 0);
 
1182
        while (snd_seq_query_next_client(handle, cinfo) >= 0) {
 
1183
                client = snd_seq_client_info_get_client(cinfo);
 
1184
                snd_seq_port_info_set_client(pinfo, client);
 
1185
                snd_seq_port_info_set_port(pinfo, -1);
 
1186
                while (snd_seq_query_next_port(handle, pinfo) >= 0) {
 
1187
                        unsigned int cap;
 
1188
                        if( io > 0 )
 
1189
                                cap = (SND_SEQ_PORT_CAP_SUBS_WRITE|SND_SEQ_PORT_CAP_WRITE);
 
1190
                        else
 
1191
                                cap = (SND_SEQ_PORT_CAP_SUBS_READ|SND_SEQ_PORT_CAP_READ);
 
1192
                        if( (snd_seq_port_info_get_capability(pinfo) & cap) == cap )
 
1193
                        {
 
1194
                                const char *name;
 
1195
                                port = snd_seq_port_info_get_port(pinfo);
 
1196
                                items[i] = Tcl_NewListObj(0, NULL);
 
1197
                                Tcl_ListObjAppendElement(interp, items[i],
 
1198
                                                        Tcl_NewIntObj(client));
 
1199
                                Tcl_ListObjAppendElement(interp, items[i],
 
1200
                                                        Tcl_NewIntObj(port));
 
1201
                                name = snd_seq_port_info_get_name(pinfo);
 
1202
                                Tcl_ListObjAppendElement(interp, items[i],
 
1203
                                                        Tcl_NewStringObj(name, strlen(name)));
 
1204
                                name = snd_seq_client_info_get_name(cinfo);
 
1205
                                Tcl_ListObjAppendElement(interp, items[i],
 
1206
                                                        Tcl_NewStringObj(name, strlen(name)));
 
1207
 
 
1208
                                Tcl_ListObjAppendElement(interp, res, items[i]);
 
1209
                                i++;
 
1210
                        }
 
1211
                }
 
1212
        }
 
1213
        
 
1214
        Tcl_SetObjResult(interp, res);
 
1215
 
 
1216
return TCL_OK;
 
1217
}
 
1218
#endif /* HAVE_SYS_ASOUNDLIB_H */
1076
1219
 
1077
1220
/*
1078
1221
        Return a given screen distance to pixels