Skip to content

Commit 309d114

Browse files
committed
fixing README.md
1 parent c48c802 commit 309d114

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ http://bohdan-danishevsky.blogspot.com/2016/12/building-codec2-for-windows-using
1313
# Usage for recording voice (encoding)
1414

1515
First of all you need open output file:
16+
```
1617
outputFile = new QFile(fileName);
1718
outputFile->open(QIODevice::WriteOnly | QIODevice::Truncate);
18-
19+
```
1920
Then you need create encoder and attach output file to the encoder:
21+
```
2022
encoder = new QCodec2Encoder(outputFile, this);
2123
encoder->setCodecMode(ui->cbBitrate->currentData().toInt());
2224
encoder->setNaturalEncoding(true);
2325
encoder->start(QIODevice::Truncate);
26+
```
2427

2528
Finally, you need initialize QAudioInput:
29+
```
2630
QAudioFormat format = QCodec2BaseClass::codec2AudioFormat();
2731
audioInput = new QAudioInput(deviceInfo, format, this);
2832
@@ -37,22 +41,28 @@ Finally, you need initialize QAudioInput:
3741
audioInput->setBufferSize(format.sampleRate()*format.channelCount()*(format.sampleSize()/8));
3842
3943
audioInput->start(m_Codec2Writer);
44+
```
4045

4146
# Usage for playing voice
4247
First of all you need open output file:
4348

49+
```
4450
audioInput = new QFile(m_WorkingFileName);
4551
audioInput->open(QIODevice::ReadOnly);
52+
```
4653

4754
Next you need create decoder:
4855

56+
```
4957
decoder = new QCodec2Decoder(audioInput, this);
5058
decoder->setCodecMode(ui->cbBitrate->currentData().toInt());
5159
decoder->setNaturalEncoding(ui->cbEncodingType->currentData().toBool());
5260
decoder->start();
61+
```
5362

5463
Finally, you need create audio QAudioOutput for plyaing decoded data:
5564

65+
```
5666
QAudioFormat format = QCodec2BaseClass::codec2AudioFormat();
5767
5868
audioOutput = new QAudioOutput(deviceInfo, format, this);
@@ -68,6 +78,7 @@ Finally, you need create audio QAudioOutput for plyaing decoded data:
6878
audioOutput->setBufferSize(format.sampleRate()*format.channelCount()*(format.sampleSize()/8));
6979
7080
audioOutput->start(decoder);
81+
```
7182

7283
# Documentation
7384

0 commit comments

Comments
 (0)