ПАЙДАЛАНҒАН ӘДЕБИЕТТЕР ТІЗІМІ
Жалпы ресурс: https://nfc.com/.
Creative OpenAL SDK: http://connect.creativelabs.com/ developer/
Devmaster.net Tutorials (in English): http://www.devmaster.net/articles/openal-tutorials/lesson1.php
Android Studio: https://developer.android.com/studio
Arduino IDE: https://www.arduino.cc/
Python: https://www.python.org/
Unity: Unity Real-Time Development Platform | 3D, 2D VR & AR Engine
Django: The web framework for perfectionists with deadlines | Django (djangoproject.com)
Том Иго. Умные вещи. Arduino, датчики и сети для связи устройств, 2015.
Анна Бочарова. Розничный магазин: с чего начать, как преуспеть, 2013.
Гульфира Крок, С. В. Сысоева. Большая книга директора магазина 2.0. Новые технологии, 2015.
Виктория Ламанова. Как превратить посетителя в покупателя. Настольная книга директора магазина, 2015.
Дэвид Льюис. Нейромаркетинг в действии. Как проникнуть в мозг покупателя, 2013.
Е. В. Шестакова. Как открыть розничный магазин?, 2015.
Денис Подольский, Дмитрий Колодник. Розничный магазин: как удвоить продажи, 2012.
"Android NDK | Android Developers". Developer.android.com. March 13, 2014.
"NDK Downloads | Android Developers". developer.android.com. Retrieved 2018-04-24.
Ratabouil, Sylvain (2015). Android NDK beginner's guide : discover the native side of Android and inject the power of C/C++ in your applications(2nd ed.).
Kosarevsky, Sergey (2013). Android NDK game development cookbook : over 70 exciting recipes to help you develop mobile games for Android in C++. Viktor Latypov.
Srinivas, Davanum (December 9, 2007). "Android — Invoke JNI based methods (Bridging C/C++ and Java)".
"java.lang.System". Android Developers. Retrieved September 3, 2009.
"What Is an Interface". The Java Tutorials. Oracle. 2012-05-01.
"Interfaces". The Java Tutorials. Oracle 2012-05-01.
Қосымша А
/* AUTO-GENERATED FILE. DO NOT MODIFY.
* Бұл класс автоматты түрде тапқан ресурс деректерінен aapt құралы. Бұны қолмен өзгертуге болмайды. */
package org.pielot.openal;
public final class R {
public static final class drawable {
public static final int ic_launcher = 0x7f020001;
}
public static final class layout {
public static final int main = 0x7f030007;
}
public static final class string {
public static final int app_name = 0x7f040001;
public static final int hello = 0x7f040000;
}
}
Дыбысты ойнату бағдарламасы.
package kz.control3dsound;
import org.pielot.openal.Buffer;
import org.pielot.openal.SoundEnv;
import org.pielot.openal.Source;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.View;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.SeekBar;
import android.widget.TextView;
public class SoundPlayer extends Activity implements SensorEventListener {
float cx, cy, radius;
int width, height;
private Boolean playing = false;
DrawBackground pbk;
DrawCanvasCircle pcc;
private float pos_x = 0.0f, pos_y = 0.0f, pos_z = 0.0f;
private String sound_name;
private int sound_position;
SensorManager mSensorManager;
Sensor mAccelerometer;
Sensor mMagnetometer;
RelativeLayout mControls;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sound_player);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
Display display = getWindowManager().getDefaultDisplay();
width = display.getWidth();
height = width;
playing = true;
cx = (float) width / 2.0f;
cy = (float) height / 2.0f;
radius = (float) (Math.min(width, height)) / 2.5f;
mControls = (RelativeLayout) findViewById (R.id.myLinearLayout);
pbk = new DrawBackground (this);
Bitmap result = Bitmap.createBitmap (width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
pbk.draw(canvas);
pbk.setLayoutParams(new LayoutParams(width, height));
mControls.addView(pbk);
pcc = new DrawCanvasCircle(this);
Bitmap circleBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas circleCanvas = new Canvas (circleBitmap);
pcc.draw(circleCanvas);
pcc.setLayoutParams(new LayoutParams(width, height));
mControls.addView(pcc);
Log.i("OnCreate", "main");
sound_name = getIntent().getExtras().getString("sound_name");
sound_position = Integer.valueOf(getIntent().getExtras().getString("sound_position"));
if (sound_position < MainActivity.numberOfBuiltInFiles) {
// TODO
} else {
sound_name = sound_name.toLowerCase();
}
}
public void redraw () {
mControls.removeViewAt(1);
pcc = new DrawCanvasCircle(this);
Bitmap circleBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas circleCanvas = new Canvas (circleBitmap);
pcc.draw(circleCanvas);
pcc.setLayoutParams(new LayoutParams(width, height));
mControls.addView(pcc);
}
public class DrawBackground extends View{
public DrawBackground(Context mContext) {
super(mContext);
}
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
canvas.drawCircle(cx, cy, radius, paint);
paint.setColor(Color.BLACK);
canvas.drawLine(cx, cy-radius, cx, cy+radius, paint);
canvas.drawLine(cx-radius, cy, cx+radius, cy, paint);
}
}
public class DrawCanvasCircle extends View{
public DrawCanvasCircle(Context mContext) {
super(mContext);
}
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.RED);
canvas.drawCircle(cx + pos_x, cy + pos_y, radius/15, paint);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.sound_player, menu);
return true;
}
@Override
public void onResume() {
super.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_UI);
playing = true;
MainActivity.SoundSources[sound_position].play(true);
Log.i("onResume", "slsls");
}
@Override
public void onRestart () {
super.onRestart();
Log.i("onRestart", "blablabla");
}
@Override
public void onStop () {
super.onStop();
MainActivity.SoundSources[sound_position].stop();
playing = false;
Log.i("onStop", "blablabla");
onDestroy();
}
@Override
public void onPause() {
super.onPause();
MainActivity.SoundSources[sound_position].stop();
playing = false;
mSensorManager.unregisterListener(this);
Log.i("onPause", "ppppspspsp");
}
@Override
public void onDestroy() {
super.onDestroy();
mSensorManager.unregisterListener(this);
MainActivity.SoundSources[sound_position].stop();
playing = false;
Log.i("onDestroy", "aaaa");
}
public void share (View v) {
Intent share = new Intent (android.content.Intent.ACTION_SEND);
share.setType("text/plain");
String shareBody = "Control 3D Sound in RealTime with your phone. Control virtual bee inside your brain!\n\nhttps://play.google.com/store/apps/details?id=kz.abzaloid.control3dsound";
String shareSubject = "Feel and Control 3D Sounds in your Brain in RealTime";
share.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSubject);
share.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(share, "Share via"));
}
@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub
}
private float [] gravity = new float[3];
private float [] geomag = new float[3];
private float [] rotationMatrix = new float[16];
@Override
public void onSensorChanged(SensorEvent event) {
int type = event.sensor.getType();
if (type == Sensor.TYPE_MAGNETIC_FIELD) {
geomag[0] = (geomag[0] * 1 + event.values[0]) * 0.5f;
geomag[1] = (geomag[1] * 1 + event.values[1]) * 0.5f;
geomag[2] = (geomag[2] * 1 + event.values[2]) * 0.5f;
} else
if (type == Sensor.TYPE_ACCELEROMETER) {
gravity[0] = (gravity[0] * 2 + event.values[0]) * 0.333334f;
gravity[1] = (gravity[1] * 2 + event.values[1]) * 0.333334f;
gravity[2] = (gravity[2] * 2 + event.values[2]) * 0.333334f;
}
if (type == Sensor.TYPE_ACCELEROMETER || type == Sensor.TYPE_MAGNETIC_FIELD) {
rotationMatrix = new float[16];
SensorManager.getRotationMatrix(rotationMatrix, null, gravity, geomag);
float angles [] = new float [3];
SensorManager.getOrientation(rotationMatrix, angles);
TextView textView = (TextView) findViewById(R.id.monitor);
SeekBar seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
int val = seekBar1.getProgress();
if (playing == true) {
pos_x = (float) Math.sin(angles[2]) * radius / 1.2f;
pos_y = (float) Math.sin(-angles[1]) * radius / 1.2f;
pos_z = (float) radius * (100 - val) / 120.0f;
redraw();
float thresholdValue = 20.0f;
float x = thresholdValue * pos_x * 1.2f / radius;
float y = thresholdValue * pos_y * 1.2f / radius;
float z = thresholdValue * pos_z * 1.2f / radius;
MainActivity.SoundSources[sound_position].setPosition(x, y, z);
textView.setText ("x = " + String.valueOf(x) + " ;\ny = " + String.valueOf(y) + " ;\nz = " + String.valueOf(z));
}
}
}
}
Достарыңызбен бөлісу: |