> For the complete documentation index, see [llms.txt](https://lcav.gitbook.io/dsp-labs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lcav.gitbook.io/dsp-labs/linear-prediction.md).

# 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](/dsp-labs/linear-prediction/theory.md), 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](/dsp-labs/linear-prediction/implementation.md), 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
