(

var

button1, button2, button3,
controls,
field1, field2, field3, field4, field5, field6,
playing,
meter, player;

field1= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /1. Tape Pieces/field recording I.wav";

field2= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /1. Tape Pieces/field recording II.wav";

field3= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /1. Tape Pieces/field recording III.wav";

field4= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /1. Tape Pieces/field recording IV.wav";

field5= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /1. Tape Pieces/field recording V.wav";

field6= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /1. Tape Pieces/field recording VI.wav";

playing = field1;

player = Player.new(playing, amp: 3, outbus: 32);

//controlos
controls = SCWindow("field recording", Rect(640, 0, 500, 270));
controls.view.background = Color.grey(0.1);

//butões
// 1-escolhe faixa
button1 = Button(controls, Rect(50, 50, 100, 100))
    .canFocus_(false)
    .states_([
	["I"],
	["II"],
	["III"],
	["IV"],
	["V"],
	["VI"]
    ])
    .action_({ arg it;
    var num = it.value;

    if(num == 1) 
	{
player.stop;
button2.value_(0);
playing = field2;
player = Player.new(playing, amp: 3, outbus: 32);		
	};
	
if(num == 2) 
	{
player.stop;
button2.value_(0);
playing = field3;		
player = Player.new(playing, amp: 3, outbus: 32);		
	};
	
if(num == 3) 
	{
player.stop;
button2.value_(0);
playing = field4;		
player = Player.new(playing, amp: 3, outbus: 32);		
	};

if(num == 4) 
	{
player.stop;
button2.value_(0);
playing = field5;		
player = Player.new(playing, amp: 3, outbus: 32);		
	};
	
if(num == 5) 
	{
player.stop;
button2.value_(0);
playing = field6;		
player = Player.new(playing, amp: 3, outbus: 32);		
	};

if(num == 0) 
	{
player.stop;
button2.value_(0);
playing = field1;		
player = Player.new(playing, amp: 3, outbus: 32);
	};
    });
button1.font_(Font("Times", 50));

//butões
// 2-toca faixa
button2 = Button(controls, Rect(200, 50, 100, 100))
    .canFocus_(false)
    .states_([
	["play"],
	["pause"]
    ])
    .action_({ arg it;
    var num = it.value;

if(num == 1) 
	{
		
player.play;

	};
if(num == 0) 
	{
		
player.pause;

	}
    });
button2.font_(Font("Lucida Grande", 12));

//butões
// 3-stop
button3 = Button(controls, Rect(350, 50, 100, 100))
    .canFocus_(false)
    .states_([
	["stop"],
    ])
    .action_({ arg it;
    var num = it.value;

if(num == 0) 
	{
		
player.stop;
button2.value_(0);

	};
    });
button3.font_(Font("Lucida Grande", 12));

controls.front;

CmdPeriod.doOnce{if(controls.isClosed.not, {controls.close;})};

)