• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Sound类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中lejos.hardware.Sound的典型用法代码示例。如果您正苦于以下问题:Java Sound类的具体用法?Java Sound怎么用?Java Sound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Sound类属于lejos.hardware包,在下文中一共展示了Sound类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import lejos.hardware.Sound; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	 GraphicsLCD g = BrickFinder.getDefault().getGraphicsLCD();
	 final int SW = g.getWidth();
	 final int SH = g.getHeight();
	 Button.LEDPattern(4);
	 Sound.beepSequenceUp();
	 g.setFont(Font.getDefaultFont());
	 g.drawString("Lejos EV3 Gradle", SW/2, SH/2, GraphicsLCD.BASELINE|GraphicsLCD.HCENTER);
	 Button.LEDPattern(3);
	 Delay.msDelay(4000);
	 Button.LEDPattern(5);
	 g.clear();
	 g.refresh();
	 Sound.beepSequence();
	 Delay.msDelay(500);
	 Button.LEDPattern(0); 
}
 
开发者ID:jornfranke,项目名称:lejos-ev3-example,代码行数:21,代码来源:RobotApplication.java


示例2: main

import lejos.hardware.Sound; //导入依赖的package包/类
public static void main(String[] args) {
	log.info("Initializing...");
	LCD.clear();
	disableOtherLogLayers();
	LCD.clear();
	Button.setKeyClickVolume(1);
	SystemTime.initSysTime();
	ClockProperties clockProperties = ClockProperties.getInstance();
	AnalogClock clock = new AnalogClock(clockProperties, new TickPeriod(5,
			TimeUnit.SECONDS), new Time(0, 20),
			MirrorMotor
					.invertMotor(new EV3MediumRegulatedMotor(MotorPort.A)),
			MirrorMotor
					.invertMotor(new EV3LargeRegulatedMotor(MotorPort.B)));
	MainWithMenu mainWithMenu = new MainWithMenu(clock);
	log.info("Ready");
	Sound.beep();
	mainWithMenu.start();
}
 
开发者ID:rafalmag,项目名称:EV3-projects,代码行数:20,代码来源:MainWithMenu.java


示例3: doLocalization

import lejos.hardware.Sound; //导入依赖的package包/类
public void doLocalization() {
	// drive to location listed in tutorial
	// start rotating and clock all 4 gridlines
	// do trig to compute (0,0) and 0 degrees
	// when done travel to (0,0) and turn to 0 degrees
	
	Navigation localizerLocomotor = new Navigation(this.odo);
	
	/* Store the angles that each axis is crossed at in an array
	 * [0] -> y-
	 * [1] -> x+
	 * [2] -> y+
	 * [3] -> x-
	 */
	ArrayList<Double> angles = new ArrayList<Double>();
	
	// Start the robot rotating
	localizerLocomotor.setSpeeds(-ROTATION_SPEED, ROTATION_SPEED);
	
	// This code assumes wer're in the third quadrant
	while(angles.size() < 4) {
		if(colorSensor.getFilteredData() < BLACK_RGB) {
			Sound.beep();
			angles.add(odo.getAng());
			Delay.msDelay(AXIS_CROSS_DELAY);
		}
	}
	localizerLocomotor.halt();
	
	// Now let's do some math
	// Lets calculate our x position
	double x = (-COLOR_SENSOR_OFFSET) * Math.cos(Math.toRadians(Math.abs(angles.get(0) - angles.get(2)))/2);
	// Lets calculate our y position
	double y = (COLOR_SENSOR_OFFSET) * Math.cos(Math.toRadians(Math.abs(angles.get(1) - angles.get(3)))/2);
	// Let's calculate our heading correction
	double headingCorrection = odo.getAng() + 270 - angles.get(0) + (Math.abs(angles.get(0) - angles.get(2)))/2;
	odo.setPosition(new double [] {x, y, headingCorrection}, new boolean [] {true, true, true});
}
 
开发者ID:alisharif2,项目名称:dpm-project,代码行数:39,代码来源:LightLocalizer.java


示例4: fire

import lejos.hardware.Sound; //导入依赖的package包/类
@Override
public void fire() {
	GlobalDefinitions.SHOOTMOTOR.rotate(-250);
	Sound.beep();
	GlobalDefinitions.SHOOTMOTOR.rotate(250);
	
}
 
开发者ID:alisharif2,项目名称:dpm-project,代码行数:8,代码来源:BallLauncher.java


示例5: dropBall

import lejos.hardware.Sound; //导入依赖的package包/类
public void dropBall(){
	GlobalDefinitions.SHOOTMOTOR.setSpeed(300);
	GlobalDefinitions.SHOOTMOTOR.rotate(500);
	Sound.beep();
	GlobalDefinitions.SHOOTMOTOR.setSpeed(50);

	GlobalDefinitions.SHOOTMOTOR.rotate(-500);
	GlobalDefinitions.SHOOTMOTOR.setSpeed(300);

}
 
开发者ID:alisharif2,项目名称:dpm-project,代码行数:11,代码来源:BallLauncher.java


示例6: stop

import lejos.hardware.Sound; //导入依赖的package包/类
public void stop() throws IOException {
    pilot.stop();
    Sound.beepSequenceUp();
    sock.close();
    server.close();
    System.exit(0);
}
 
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:8,代码来源:Megatron.java


示例7: Megatron

import lejos.hardware.Sound; //导入依赖的package包/类
public Megatron() {
    ev3 = BrickFinder.getDefault();
    setupPilot();
    setupColorSensor();
    getColorName();
    setupUltrasonicSensor();
    setupServer();
    stoppingThread = new StoppingThread(this);
    stoppingThread.start();
    while (true) {
        try {
            String command = input.readLine();
            System.out.println("Command: " + command);
            if (command.equals("get(color)")) {
                pilot.travel(-MOVE_BACK_DISTANCE);
                String theColor = getColorName();
                pilot.travel(MOVE_BACK_DISTANCE);
                if (theColor.equals(BLUE) || theColor.equals(RED) || theColor.equals(GREEN))
                    Sound.beep();
                output.println(theColor);
            } else if (command.equals("get(occupied)")) {
                output.println(getOccupiedInfo());
            } else if (command.startsWith("move")) {
                String[] parameters = getParameters(command);
                output.println(moveRelatively(parameters[0],parameters[1]));
                firstStepFinished = true;
            } else if (command.equals("end")) {
                doCelebration();
                output.println(DONE);
            }
            output.flush();
        } catch (IOException e) {
        }
    }
}
 
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:36,代码来源:Megatron.java


示例8: uncaughtException

import lejos.hardware.Sound; //导入依赖的package包/类
@Override
public void uncaughtException(Thread th, Throwable t)  {
	Sound.buzz();
    TextLCD lcd = LocalEV3.get().getTextLCD(Font.getSmallFont());
    int offset = 0;
    while (true)
    {
   		lcd.clear();
   		lcd.drawString("Uncaught exception:", offset, 0);
   		lcd.drawString(t.getClass().getName(), offset, 2);
   		if (t.getMessage() != null) lcd.drawString(t.getMessage(), offset, 3);		
   		
   		if (t.getCause() != null) {
   			lcd.drawString("Caused by:", offset, 5);
   			lcd.drawString(t.getCause().toString(), offset, 6);
   		}
   		
   		StackTraceElement[] trace = t.getStackTrace();
   		for(int i=0;i<7 && i < trace.length ;i++) lcd.drawString(trace[i].toString(), offset, 8+i);
   		
   		lcd.refresh();
   		int id = Button.waitForAnyEvent();
   		if (id == Button.ID_ESCAPE) break;
   		if (id == Button.ID_LEFT) offset += 5;
   		if (id == Button.ID_RIGHT)offset -= 5;
   		if (offset > 0) offset = 0;
    }
    
    // Shutdown the EV3
   	try {
		Runtime.getRuntime().exec("init 0");
	} catch (IOException e) {
		// Ignore
	}
    System.exit(1);
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:37,代码来源:ExceptionHandler.java


示例9: playTune

import lejos.hardware.Sound; //导入依赖的package包/类
/**
 * Play the leJOS startup tune.
 */
static void playTune()
{
    if (Sound.playSample(new File("lejos.wav")) == 0)
       return;
    int[] freq = { 523, 784, 659 };
    for (int i = 0; i < 3; i++) {
        Sound.playTone(freq[i], 300);
        //Sound.pause(300);
    }
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:14,代码来源:TuneThread.java


示例10: detect_obstacle

import lejos.hardware.Sound; //导入依赖的package包/类
private void detect_obstacle()
{
    if (sensor.distance() < 30)         // If we are close to an obstacle inhibit DriveForward.output thereby stopping the robot
    {
        log("Obstacle Detected");

        mOutput.inhibit();

        log("Inhibiting Output");

        if (++mCount >= MAXCOUNT)       // If the number of obstacles detected to date exceeds MAXCOUNT we stop execution
        {
            log(String.format("Obstacle # %d. Stopping robot.", mCount));

            Sound.twoBeeps();           // Beep twice to signal the end of the program

            hold(200);      // Wait for 200 ms and then shutdown the program
            BumperCar.exit();       // Initiate graceful exit strategy
            hold(200);              // Wait for 200 ms to allow the exit to proceed
        }
        else                            // Carry out the behavior required by this module when an obstacle is detected
        {
            hold(100);          // We stop the forward motion, reverse a bit to create space and then turn left
            short_reverse();
            turn_left();

            mOutput.allow();        // Removes inhibition on the Output allowing that module to access it

            log("Removing inhibition on Output");
        }
    }
}
 
开发者ID:abid-mujtaba,项目名称:ev3-BumperCar,代码行数:33,代码来源:BumperCar.java


示例11: promptForStartPush

import lejos.hardware.Sound; //导入依赖的package包/类
void promptForStartPush() {
    logger.trace("promptForStartPush");
    Sound.twoBeeps();
    Sound.beep();
    LCD.clear();
    LCD.drawString("Please push any", 1, 1);
    LCD.drawString("button to begin.", 1, 3);
    Button.waitForAnyPress();
    LCD.clear();
    LCD.drawString("Running...", 1, 1);
}
 
开发者ID:RadicalZephyr,项目名称:ev3java,代码行数:12,代码来源:Main.java


示例12: should_play_file

import lejos.hardware.Sound; //导入依赖的package包/类
@Test
public void should_play_file() throws Exception {
	// given
	try (InputStream is = getClass().getResourceAsStream(
			"/" + Cuckoo.CUCKOO_WAV)) {
		if (is == null) {
			throw new IOException("Cannot find wav=" + Cuckoo.CUCKOO_WAV);
		}
		SoundMock soundMock = new SoundMock(new NativeDeviceMock());
		// when
		int errorCode = soundMock.playSample(is, Sound.VOL_MAX);
		// then
		assertThat(errorCode, equalTo(0));
	}
}
 
开发者ID:rafalmag,项目名称:EV3-projects,代码行数:16,代码来源:SoundFileTest.java


示例13: main

import lejos.hardware.Sound; //导入依赖的package包/类
public static void main(String[] args) {
    LCD.clear();
    LCD.drawString("First EV3 Program", 0, 5);
    Sound.beep();
    Button.waitForAnyPress();
    LCD.clear();
    LCD.refresh();

}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:10,代码来源:HelloWorld.java


示例14: startBeeps

import lejos.hardware.Sound; //导入依赖的package包/类
/**
 * Warn user the Ballbot is about to start balancing. 
 */
private static void startBeeps() {
	LCD.clear();
	LCD.drawString("leJOS NXJ Ballbot", 0, 1);
	LCD.drawString("Balance in", 0, 3);

	// Play warning beep sequence to indicate balance about to start
	for (int c=8; c>=0;c--) {
		LCD.drawInt(c, 5, 4);
		Sound.playTone(440,100);
		try { Thread.sleep(1000);
		} catch (InterruptedException e) {}
	}
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:17,代码来源:Ballbot.java


示例15: playTone

import lejos.hardware.Sound; //导入依赖的package包/类
@Override
public void playTone(int freq, int duration) throws RemoteException {
	Sound.playTone(freq, duration);
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:5,代码来源:RMIRemoteSound.java


示例16: showNotify

import lejos.hardware.Sound; //导入依赖的package包/类
protected void showNotify() {
	// Play notification sound
	new Thread() {
		public void run() {
			Sound.beepSequenceUp();
		}
	}.start();
	
	// Start painting alert screen
	repaint();
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:12,代码来源:Alert.java


示例17: pullElasticBack

import lejos.hardware.Sound; //导入依赖的package包/类
public void pullElasticBack(){
	GlobalDefinitions.RELOADMOTOR.setSpeed(600);
	GlobalDefinitions.RELOADMOTOR.rotate(362*27);
	Sound.beep();
	GlobalDefinitions.RELOADMOTOR.rotate(-362*27);
}
 
开发者ID:alisharif2,项目名称:dpm-project,代码行数:7,代码来源:BallLauncher.java


示例18: doCelebration

import lejos.hardware.Sound; //导入依赖的package包/类
private void doCelebration() {
    Sound.beepSequence();
    Sound.beepSequenceUp();
    Sound.beep();
}
 
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:6,代码来源:Megatron.java


示例19: run

import lejos.hardware.Sound; //导入依赖的package包/类
@Override
public void run() {
	
	initBrick();
	
	/*
	
	// --------------- OLD ----------------------
	new Thread(){
		@Override
		public void run() {
			try {
				new UnregulatedMotorEndpoint(MotorPort.A, NetworkPortConfig.MOTOR_PORT_A);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}.start();
	
	new Thread(){
		@Override
		public void run() {
			try {
				new UnregulatedMotorEndpoint(MotorPort.D, NetworkPortConfig.MOTOR_PORT_D);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}.start();
	
	new Thread(){
		@Override
		public void run() {
			try {
				new EV3ColorSensorEndpointEndpoint(SensorMode_.RED, SensorPort.S1, NetworkPortConfig.SENSOR_PORT_1);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}.start();
	
	new Thread(){
		@Override
		public void run() {
			try {
				new EV3ColorSensorEndpointEndpoint(SensorMode_.RED, SensorPort.S4, NetworkPortConfig.SENSOR_PORT_4);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}.start();
	
	new Thread(){
		@Override
		public void run() {
			try {
				new EV3UltrasonicSensorEndpointEndpoint(SensorMode_.DISTANCE, SensorPort.S2, NetworkPortConfig.SENSOR_PORT_2);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}.start();
	*/
	Button.ESCAPE.waitForPressAndRelease();
	Sound.playTone(1000, 3);
	System.exit(0);		
}
 
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:68,代码来源:App.java


示例20: toolException

import lejos.hardware.Sound; //导入依赖的package包/类
private void toolException(Throwable t) {
    Sound.buzz();
    TextLCD lcd = BrickFinder.getDefault().getTextLCD(Font.getSmallFont());
    int offset = 0;
    // Get rid of invocation exception
    if ( t.getCause() != null ) {
        t = t.getCause();
    }
    while ( true ) {
        lcd.clear();
        lcd.drawString("Tool exception:", offset, 1);
        lcd.drawString(t.getClass().getName(), offset, 3);
        if ( t.getMessage() != null ) {
            lcd.drawString(t.getMessage(), offset, 4);
        }

        if ( t.getCause() != null ) {
            lcd.drawString("Caused by:", offset, 5);
            lcd.drawString(t.getCause().toString(), offset, 6);
        }

        StackTraceElement[] trace = t.getStackTrace();
        for ( int i = 0; i < 7 && i < trace.length; i++ ) {
            lcd.drawString(trace[i].toString(), offset, 8 + i);
        }

        lcd.refresh();
        int id = Button.waitForAnyEvent();
        if ( id == Button.ID_ESCAPE ) {
            break;
        }
        if ( id == Button.ID_LEFT ) {
            offset += 5;
        }
        if ( id == Button.ID_RIGHT ) {
            offset -= 5;
        }
        if ( offset > 0 ) {
            offset = 0;
        }
    }
    lcd.clear();
}
 
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:44,代码来源:GraphicStartup.java



注:本文中的lejos.hardware.Sound类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultRepositoryLayout类代码示例发布时间:2022-05-21
下一篇:
Java ObjectTable类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap