मैं एंड्रॉइड फोन के माइक के लाभ को बढ़ाने की कोशिश कर रहा हूं ताकि वह बहुत ही मिनट की आवाज़ सुनने में सक्षम हो। क्या यह संभव है? कृपा करके आप इस बारे में मेरी मदद कर सकते हैं।क्या हम एंड्रॉइड फोन के माइक के लाभ को बढ़ा सकते हैं?
उत्तर
this link आपको आगे ले जाना चाहिए। वॉल्यूम उच्च सेट करने के लिए setStreamVolume (...) का उपयोग करें। लेकिन ध्यान दें कि getStreamMaxVolume (...) को कॉल करके अधिकतम अधिकतम पूछा जा सकता है। इसलिए माइक लाभ शायद हार्डवेयर द्वारा सीमित है जो मुझे लगता है। तो यह "ऑन-फ्लाई" करना संभव नहीं है, लेकिन थोड़ा रिकॉर्डिंग के बारे में क्या है, equalizer द्वारा विशेष आवृत्ति को बढ़ाने की कोशिश कर रहा है और फिर दिल की धड़कन की तरह कुछ पहचान सकता है? मुश्किल लगता है लेकिन शायद संभव है।
सूचीबद्ध धाराओं में से कौन सा mic के लिए है? – Davita
ऑडियो लाभ नियंत्रण
public class MainActivity extends Activity {
public static final int SAMPLE_RATE = 16000;
private AudioRecord mRecorder;
private File mRecording;
private short[] mBuffer;
private final String startRecordingLabel = "Start recording";
private final String stopRecordingLabel = "Stop recording";
private boolean mIsRecording = false;
private ProgressBar mProgressBar;
float iGain = 1.0f;
CheckBox gain;
protected int bitsPerSamples = 16;
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
initRecorder();
Button bluetooth = (Button)findViewById(R.id.blue);
gain = (CheckBox) findViewById(R.id.checkBox1);
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
final Button button = (Button) findViewById(R.id.start);
button.setText(startRecordingLabel);
bluetooth.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent("");
}
});
gain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (gain.isChecked()) {
iGain = 5.0f;
} else {
iGain = 2.0f;
}
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
if (!mIsRecording) {
button.setText(stopRecordingLabel);
mIsRecording = true;
mRecorder.startRecording();
mRecording = getFile("raw");
startBufferedWrite(mRecording);
} else {
button.setText(startRecordingLabel);
mIsRecording = false;
mRecorder.stop();
File waveFile = getFile("wav");
try {
rawToWave(mRecording, waveFile);
} catch (IOException e) {
Toast.makeText(MainActivity.this, e.getMessage(),
Toast.LENGTH_SHORT).show();
}
Toast.makeText(MainActivity.this,
"Recorded to " + waveFile.getName(),
Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public void onDestroy() {
mRecorder.release();
super.onDestroy();
}
private void initRecorder() {
int bufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
mBuffer = new short[bufferSize];
mRecorder = new AudioRecord(MediaRecorder.AudioSource.MIC, SAMPLE_RATE,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT,
bufferSize);
}
private void startBufferedWrite(final File file) {
new Thread(new Runnable() {
@Override
public void run() {
DataOutputStream output = null;
try {
output = new DataOutputStream(new BufferedOutputStream(
new FileOutputStream(file)));
while (mIsRecording) {
double sum = 0;
int readSize = mRecorder.read(mBuffer, 0,
mBuffer.length);
final int bytesPerSample = bitsPerSamples/8;
final int emptySpace = 64 - bitsPerSamples;
int byteIndex = 0;
int byteIndex2 = 0;
int temp = 0;
int mLeftTemp = 0;
int mRightTemp = 0;
int a = 0;
int x = 0;
for (int frameIndex = 0; frameIndex < readSize; frameIndex++) {
for (int c = 0; c < 1; c++) {
if (iGain != 1) {
long accumulator = 0;
for (int b = 0; b < bytesPerSample; b++) {
accumulator += ((long) (mBuffer[byteIndex++] & 0xFF)) << (b * 8 + emptySpace);
}
double sample = ((double) accumulator/(double) Long.MAX_VALUE);
sample *= iGain;
int intValue = (int) ((double) sample * (double) Integer.MAX_VALUE);
for (int i = 0; i < bytesPerSample; i++) {
mBuffer[i + byteIndex2] = (byte) (intValue >>> ((i + 2) * 8) & 0xff);
}
byteIndex2 += bytesPerSample;
}
}// end for(channel)
// mBuffer[frameIndex] *=iGain;
if (mBuffer[frameIndex] > 32765) {
mBuffer[frameIndex] = 32767;
} else if (mBuffer[frameIndex] < -32767) {
mBuffer[frameIndex] = -32767;
}
output.writeShort(mBuffer[frameIndex]);
sum += mBuffer[frameIndex] * mBuffer[frameIndex];
}
if (readSize > 0) {
final double amplitude = sum/readSize;
mProgressBar.setProgress((int) Math.sqrt(amplitude));
}
}
} catch (IOException e) {
Toast.makeText(MainActivity.this, e.getMessage(),
Toast.LENGTH_SHORT).show();
} finally {
mProgressBar.setProgress(0);
if (output != null) {
try {
output.flush();
} catch (IOException e) {
Toast.makeText(MainActivity.this, e.getMessage(),
Toast.LENGTH_SHORT).show();
} finally {
try {
output.close();
} catch (IOException e) {
Toast.makeText(MainActivity.this, e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
}
}
}
}).start();
}
private void rawToWave(final File rawFile, final File waveFile)
throws IOException {
byte[] rawData = new byte[(int) rawFile.length()];
DataInputStream input = null;
try {
input = new DataInputStream(new FileInputStream(rawFile));
input.read(rawData);
} finally {
if (input != null) {
input.close();
}
}
DataOutputStream output = null;
try {
output = new DataOutputStream(new FileOutputStream(waveFile));
// WAVE header
// see http://ccrma.stanford.edu/courses/422/projects/WaveFormat/
writeString(output, "RIFF"); // chunk id
writeInt(output, 36 + rawData.length); // chunk size
writeString(output, "WAVE"); // format
writeString(output, "fmt "); // subchunk 1 id
writeInt(output, 16); // subchunk 1 size
writeShort(output, (short) 1); // audio format (1 = PCM)
writeShort(output, (short) 1); // number of channels
writeInt(output, SAMPLE_RATE); // sample rate
writeInt(output, SAMPLE_RATE * 2); // byte rate
writeShort(output, (short) 2); // block align
writeShort(output, (short) 16); // bits per sample
writeString(output, "data"); // subchunk 2 id
writeInt(output, rawData.length); // subchunk 2 size
// Audio data (conversion big endian -> little endian)
short[] shorts = new short[rawData.length/2];
ByteBuffer.wrap(rawData).order(ByteOrder.LITTLE_ENDIAN)
.asShortBuffer().get(shorts);
ByteBuffer bytes = ByteBuffer.allocate(shorts.length * 2);
for (short s : shorts) {
// Apply Gain
/*
* s *= iGain; if(s>32767) { s=32767; } else if(s<-32768) {
* s=-32768; }
*/
bytes.putShort(s);
}
output.write(bytes.array());
} finally {
if (output != null) {
output.close();
}
}
}
private File getFile(final String suffix) {
Time time = new Time();
time.setToNow();
return new File(Environment.getExternalStorageDirectory(),
time.format("%Y%m%d%H%M%S") + "." + suffix);
}
private void writeInt(final DataOutputStream output, final int value)
throws IOException {
output.write(value >> 0);
output.write(value >> 8);
output.write(value >> 16);
output.write(value >> 24);
}
private void writeShort(final DataOutputStream output, final short value)
throws IOException {
output.write(value >> 0);
output.write(value >> 8);
}
private void writeString(final DataOutputStream output, final String value)
throws IOException {
for (int i = 0; i < value.length(); i++) {
output.write(value.charAt(i));
}
}
}
हाय @ शिवराज पाटिल, क्या आप अपने कोड के बारे में समझा सकते हैं। क्या यह माइक वॉल्यूम बढ़ाता है? जैसा कि मैंने देखा, यह आउटपुट फ़ाइल को संशोधित करता है, हम माइक्रोफ़ोन का उपयोग करते समय नहीं देख सकते हैं। – phongvan
यह प्रत्येक नमूने में औसत लाभ को गुणा करके आयाम बढ़ाता है ताकि आप लाभ मूल्य समायोजित करके मात्रा बढ़ा या घटा सकें। मुझे यकीन नहीं है कि हम mic का लाभ प्राप्त कर सकते हैं क्योंकि माइक्रो लाभ शायद हार्डवेयर द्वारा सीमित है। क्या मुझे पता चलेगा कि आप वास्तव में क्या करने की कोशिश कर रहे हैं? –
- 1. क्या हम अपने एंड्रॉइड फोन के माइक्रोफोन ड्राइवर का उपयोग कर सकते हैं
- 2. क्या आप एंड्रॉइड उपकरणों पर कंपन क्षमता बढ़ा सकते हैं?
- 3. हम स्पिनर के पृष्ठभूमि रंग को कैसे बदल सकते हैं?
- 4. हम स्थानीय चर घोषित कैसे कर सकते हैं और इसका मूल्य कैसे बढ़ा सकते हैं?
- 5. कोरआउट के लाभ क्या हैं?
- 6. क्या हम एंड्रॉइड में एक फ़ोल्डर एन्क्रिप्ट कर सकते हैं?
- 7. क्या हम sandcastle तेज कर सकते हैं?
- 8. क्या हम जावास्क्रिप्ट के साथ 302 रीडायरेक्ट कर सकते हैं?
- 9. हम nstimer के बजाय क्या उपयोग कर सकते हैं?
- 10. क्या हम LINQ के साथ डेटाटेबल फ़िल्टर कर सकते हैं?
- 11. क्या केकपीएचपी सुरक्षित बनाता है, और हम इसकी सुरक्षा कैसे बढ़ा सकते हैं?
- 12. हम प्रक्रिया के समय को कैसे गिन सकते हैं?
- 13. क्या हम खुद को एक ईओएफ चरित्र लिख सकते हैं?
- 14. क्या हम सीधे नोड्स को नोडलिस्ट से निकाल सकते हैं?
- 15. क्या हम इमाक्स को चर की परिभाषा ढूंढ सकते हैं?
- 16. क्या हम एडाप्टर से startActivityForResult को कॉल कर सकते हैं?
- 17. क्या हम * .dll.config को ऑटोकॉपी कर सकते हैं?
- 18. क्या हम विंडोज फोन में रेसएक्स फ़ाइल में कैरिज रिटर्न ('\ n') जोड़ सकते हैं?
- 19. हम बीडीडी परिदृश्यों के मामूली क्रमपरिवर्तन कैसे संभाल सकते हैं?
- 20. हम एमुलेटर में ".db" को कैसे दबा सकते हैं?
- 21. क्या आप एक कक्षा में दो कक्षाएं बढ़ा सकते हैं?
- 22. हम एंड्रॉइड में स्वचालित चमक कैसे बंद कर सकते हैं?
- 23. क्या आप फेसबुक/ट्विटर/आदि को शामिल करने के लिए Google पहचान टूलकिट बढ़ा सकते हैं?
- 24. एलएलवीएम के सबसे बड़े लाभ क्या हैं?
- 25. DNS सर्वर से DNS क्वेरी को आगे बढ़ा सकते हैं?
- 26. क्या हम स्रोत नियंत्रण टाइमआउट त्रुटियों को अनदेखा करने के लिए CruiseControl.NET को बता सकते हैं?
- 27. हम एचटीएमएल 5 के साथ कितना अर्थपूर्ण हो सकते हैं?
- 28. क्या हम अपने एंड्रॉइड ऐप
- 29. एंड्रॉइड: फोन कॉल के दौरान धीमी नेटवर्क
- 30. क्या हम संपूर्ण कॉन्फ़िगरेशन फ़ाइल एन्क्रिप्ट कर सकते हैं?
उपयोग के मामले में क्या है? –
मैं मोबाइल के माध्यम से दिल की धड़कन सुनने की कोशिश कर रहा हूं ... इसलिए इसके लिए मुझे एक और संवेदनशील माइक की आवश्यकता है। अगर हम mic के लाभ में वृद्धि कर सकते हैं तो यह मेरे लिए उपयोगी होगा – srikanth
दिलचस्प। यहां एक नज़र डालें: http://developer.android.com/reference/android/media/AudioManager.html –