# 6. LINEAR PREDICTION

In this exercise, we enhance our granular synthesis pitch shifter by using [Linear Predictive Coding](https://en.wikipedia.org/wiki/Linear_predictive_coding) (LPC). Although our real-time implementation already does a good job in lowering the pitch, the result may sound *unnatural*. The motivation behind using LPC is to preserve the energy envelope of the initial speech **throughout the transformation** in order to improve the output quality.

In [Section 6.1](https://lcav.gitbook.io/dsp-labs/linear-prediction/theory), we briefly explain the theory behind LPC. In particular, we will see that there exists an intuitive model to describe the production of human speech. This model results in a system of linear equations that needs to be solved (for each buffer) in order to keep this energy envelope untouched.

In [Section 6.2](https://lcav.gitbook.io/dsp-labs/linear-prediction/implementation), we implement the code that solves the set of equations presented in Section 6.1. We then guide you on the use of this code in order to improve the quality of the granular synthesis effect from the previous chapter.

As before, text contained in highlighted boxes, as shown below, will require ***you*** to determine the appropriate solution/implementation.

{% hint style="info" %}
TASK: This is a task for you!
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lcav.gitbook.io/dsp-labs/linear-prediction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
