Here is a section from John Calvin’s Institutes on prayer (III:XX:7). I have removed Scripture references unless he quotes the passage in full.
For this reason, they who delight in their own foulness aspire not at all [to prayer]. Lawful prayer, therefore, demands repentance. Hence arises the commonplace in Scripture that God does not hearken unto the wicked, and that their prayers-just as their sacrifices-are abominable to him. For it is right that they who bar their hearts should find God’s ears closed, and that they who by their hardheartedness provoke his severity should not feel him conciliatory. In Isaiah he threatens in this way, “Even though you multiply your prayers, I will not listen; for your hands are full of blood” (Isaiah 1:15). Again, in Jeremiah, “I cried out…and they refused to listen;…they will cry out in return, and I will not listen” (Jeremiah 11:7, 8, 11). For he counts it as the height of dishonor for wicked men, who all their lives besmirch his sacred name, to boast of his covenant. Consequently, in Isaiah he complains when the Jews “draw near to him with their lips…their hearts are far from him” (Isaiah 29:13). He does not, indeed, restrict this to prayers alone but declares that falsity in any part of his worship is abhorrent to him. That statement of James applies here. “You seek, and do not receive because you ask wrongly to spend it on your passions” (James 4:3). It is indeed true, as we shall see again later, that the prayers poured out by the godly do not depend upon their worthiness; yet John’s warning is not superfluous; “We receive from him whatever we ask because we keep his commandments” (I John 3:22), while a bad conscience closes the door to us. From this it follows that only sincere worshipers of God pray aright and are heard. Let each one, therefore, as he prepares to pray be displeased at his own evil deeds, and (something that cannot happen without repentance) let him take the person and disposition of a beggar.
For our prayers to be heard we must hate our sins, repent of them, trust in Christ’s blood to take our them away, and grow in holiness. Otherwise our bad conscience and our wicked deeds will put a ceiling over our heads and God will close his ears to us.