예제 #1
0
파일: a10.c 프로젝트: SoftwareHouse/Task3
void main()
{
	struct student * head,* stu;
	int search_num,del_num;
	printf("input records:\n");
    head=CreateLink();
    PrintLink(head);
	printf("\nplease input a number for search:\n");
    scanf("%d",&search_num);
    struct student * p=SearchId(head,search_num);
    printf("\nplease input a inserted num:\n");
	stu=(struct student *)malloc(LEN);
	scanf("%d,%s,%f",&stu->num,&stu->name,&stu->score);
	while(stu->num!=0)
	{
		head=InsertNote(head,stu);
		PrintLink(head);
		printf("input the inserted record:");
		stu=(struct student *)malloc(LEN);
	    scanf("%d,%s,%f",&stu->num,&stu->name,&stu->score);
	}
    printf("\ninput the deleted number:");
	scanf("%d",&del_num);
	while(del_num!=0)
	{
		head=DeleteNote(head,del_num);
		PrintLink(head);
		printf("\ninput the deleted number:");
		scanf("%d",&del_num);
	}
    DeleteLink(head);
}
예제 #2
0
void InsertNoteCurrPos(struct Tracker_Windows *window, float notenum, bool polyphonic, float velocity){
  if(notenum<0.001 || notenum>127.9) return;

  ADD_UNDO(Notes_CurrPos(window));

  struct WBlocks *wblock        = window->wblock;
  struct WTracks *wtrack        = wblock->wtrack;
  struct Tracks  *track         = wtrack->track;
  int             curr_realline = wblock->curr_realline;

  const Trs &trs = TRS_get(wblock, wtrack, curr_realline);

  if (polyphonic==false && trs.size() > 0) {
    const TrackRealline2 &tr2 = trs[0];

    if (tr2.pitch != NULL) {
      tr2.pitch->note = notenum; // lock not necessary
      maybe_scroll_down(window);
      return;
    }


    if (tr2.note != NULL) {

      // lock not necessary
      if (tr2.is_end_pitch)
        tr2.note->pitch_end = notenum;
      else
        tr2.note->note = notenum;
      
      maybe_scroll_down(window);
      return;
    }

    const struct Stops *stop = tr2.stop;
    PLAYER_lock();{
      ListRemoveElement3(&track->stops, &stop->l);
    }PLAYER_unlock();
  }

  struct LocalZooms *realline = wblock->reallines[curr_realline];
  
  InsertNote(
             wblock,wtrack,&realline->l.p,NULL,notenum,
             velocity < 0.0 ? NOTE_get_velocity(wtrack->track) : velocity*MAX_VELOCITY,
             polyphonic
             );

  if(wtrack->l.num==wblock->right_track && polyphonic)
    UpdateAllWTracksCoordinates(window,wblock);

  if (!polyphonic)
    maybe_scroll_down(window);
}
예제 #3
0
int addNote2(float notenum,int velocity,
             int line,int counter,int dividor,
             int end_line,int end_counter,int end_dividor, 
             int windownum, int blocknum, int tracknum)
{
  struct Tracker_Windows *window;
  struct WBlocks *wblock=getWBlockFromNumA(-1,&window,blocknum);
  struct WTracks *wtrack=getWTrackFromNum(windownum,blocknum,tracknum);
  if(wblock==NULL || wtrack==NULL) {
    GFX_Message(NULL, "unknown wblock(%p) or wtrack(%p) %d/%d/%d\n",wblock,wtrack,windownum,blocknum,tracknum);
    return -1;
  }

  Place *place = PlaceCreate(line,counter,dividor);

  ValidatePlace(place);

  if (!PlaceLegal(wblock->block, place)) {
    GFX_Message(NULL, "Place %d + %d/%d is not legal", line, counter, dividor);
    return -1;
  }

  Place *end_place = end_line==-1 ? NULL : PlaceCreate(end_line,end_counter,end_dividor);

  ValidatePlace(end_place);

  if (end_place != NULL && !PlaceLegal(wblock->block, end_place)) {
    GFX_Message(NULL, "Place %d + %d/%d is not legal", end_line, end_counter, end_dividor);
    return -1;
  }

  struct Notes *note = InsertNote(wblock,
                                  wtrack,
                                  place,
                                  end_place,
                                  notenum,
                                  velocity,
                                  true);

  window->must_redraw=true;

  return ListFindElementPos3(&wtrack->track->notes->l,&note->l);
}
예제 #4
0
int addNote(int notenum,int velocity,
            int line,int counter,int dividor,
            int end_line,int end_counter,int end_dividor, 
            int windownum, int blocknum, int tracknum)
{
  struct WBlocks *wblock=getWBlockFromNum(windownum,blocknum);
  struct WTracks *wtrack=getWTrackFromNum(windownum,blocknum,tracknum);
  if(wblock==NULL || wtrack==NULL) {
    RError("unknown wblock(%p) or wtrack(%p) %d/%d/%d\n",wblock,wtrack,windownum,blocknum,tracknum);
    return -1;
  }

  struct Notes *note = InsertNote(wblock,
                                  wtrack,
                                  PlaceCreate(line,counter,dividor),
                                  end_line==-1 ? NULL : PlaceCreate(end_line,end_counter,end_dividor),
                                  notenum,
                                  velocity,
                                  true);

  wblock->block->is_dirty = true;

  return ListFindElementPos3(&wtrack->track->notes->l,&note->l);
}
예제 #5
0
static void r_add_note(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack, Place *p){
  float notenum = request_notenum(window, "Add note", -1);
  
  if(notenum > 0.0f)
    InsertNote(wblock, wtrack, p, NULL, notenum, NOTE_get_velocity(wtrack->track), false);
}
예제 #6
0
static void Glissando(
	struct WBlocks *wblock,
	struct WTracks *wtrack,
	struct Notes *note1
){
//	struct Notes *note;
	struct Notes *note2=NextNote(note1);
	float f1,f,f2;
	Place p;
	int notenote;
	int notediff;

	if(note2==NULL) return;

	notediff=R_ABS(note2->note-note1->note);
	if(notediff==0 || notediff==1) return;

	f1=GetfloatFromPlacement(&note1->l.p);
	f2=GetfloatFromPlacement(&note2->l.p);

        bool up = note2->note > note1->note;

	for(notenote=note1->note;;){

          if (up)
            notenote++;
          else
            notenote--;
          
                if (up){
                  if (notenote>=note2->note)
                    break;
                } else {
                  if (notenote<=note2->note)
                    break;
                }

		f=f1+(
				R_ABS(note1->note-notenote)*(f2-f1)
				/
				notediff
				);
                if (f<0)
                  f=0;
                  
                if (f>=wblock->block->num_lines)
                  break;
                
                Float2Placement(f,&p);                  
                  
		InsertNote(
                           wblock,
                           wtrack,
                           &p,NULL,
                           notenote,
                           (int)(note1->velocity+(
                                                  ((f-f1)*(note2->velocity-note1->velocity))/(f2-f1)
                                                  )),
                           false
                           );

	}

}